Fix typo in return type for 'free'
Flush file correctly when closing.