Flushing buffer after opening file stream