Adding flush() when writing logfiles.