fo.close()
fe.close()
if not erroroutput:
    return retval
else:
    raise OSError('Executing the command caused an error: %s' % erroroutput)
Best way to extract text from a Word doc without using COM/automation?