title: Python - Writing to text files, but they show up empty?
body: <p>I'm reading a .docx file to extract the tables it has in it and re-write each table to a .txt file. I am able to print the rows and columns in the terminal and create all .txt files for each table, but the files created are empty. Here is what I have:</p>
  <pre><code>from docx import Document
  
  document = Document('my_doc.docx')
  tables = document.tables #Stores all tables in this variable
  c = 1
  for table in tables:
      for row in table.rows:
          for cell in row.cells:
              for paragraph in cell.paragraphs:
                  print(paragraph.text)
                  with open('table_'+str(c)+'.txt', 'w') as f:
                      f.write(paragraph.text)
      c += 1
  </code></pre>
  <p>If I do <code>f.write(str(paragraph))</code> instead of <code>f.write(paragraph.text)</code>, it only writes the location where the tables are stored. What am I doing wrong? How can I save the actual content of the tables to the text files?
  Thanks!</p>