Add file flushing on write