fix a bug in file message writer causing the output file to be empty from time to time