flush output files after every write, in case of crashes