Don't call flush() before close to improve performance