write the document