Saving a document in a doc-based app

In a doc-based app i’m making, i am using write to file and read from file to write and read a list from a document. When i save a document the first time it saves it normaly and every thing is fine. when i open it again and save it after making changes it goes through all the code in the write to file handler fine, but says ‘Could not save file’.

any ideas?