adding flush() on output files