Made a few changes for the file writing.