Fixed writeToFile.