File output is now only done on exit