Added file output.

Can now redirect output to output.txt in append-mode.
Option to disable is a boolean at the beginning of the code.