fn write_doc(file: &Path, doc: &DocumentMut) -> Result<(), String>
Writes the file whole, through a file beside it, so that it is never half written.