Fixed an issue when writing out to the file.