buffer file flushing