File flushing algorithm in the printer