<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def doc_reader(infile):
 """Parse docx and odf files."""

    if infile.endswith('.docx'):
        docid = 'word/document.xml'
    else:
        docid = 'content.xml'
    try:
        zfile = zipfile.ZipFile(infile)
    except:
        print('Sorry, can\'t open {}.'.format(infile))
        return
    body = ET.fromstring(zfile.read(docid))
    text = '\n'.join([et.text.strip() for et in body.iter() if et.text])
    return text