<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_document(doc, fnm):
 """Write a Text document to file. Parameters doc: Text The document to save. fnm: str The filename to save the document """

    with codecs.open(fnm, 'wb', 'ascii') as f:
        f.write(json.dumps(doc, indent=2))