Too many stacked Strings

This reply is meant for the OP.

Two options using SWI-Prolog:

  1. Protocol/1 (Used to capture screen to file)
  2. Use tell/1 and told/0. e.g. tell('my_file.txt'), goal(Arguments), told.