[fix] Fix the message loss at file open stage

I had a doubt that there was a bug to cause the loss of message buffered between file.flush() and once('flush'). And I made a fix but I am not sure that this is a correct one. Please check this out.