Fixed an issue with the end of the file not being written.