Added a section of code to prevent writes that would corrupt the file.
Also removed the persistant file writer.