http://qs1969.pair.com?node_id=962598


in reply to print the output on the screen and to a file

One other possibility is consolidate all for your print statements into calls to one central printing function that prints to both the screen and the file. This has the advantage that all of your I/O is passes through a single function. If, sometime in the future, you want to change how you do your output (use one of the Log:: modules or some similar change) then your changes are limited to one routine.

Such a change is simple to implement at the start of development, but it is a large, time-consuming, and error-prone task when applied to existing code. (I've had to do both.)