title: Python filewriting with write(), writelines(), to_csv() not working
body: <p>I'm running a piece of code which takes input from a txt file, uses the input to scrape a tor webpage and then gives a list of strings called result. I'm using the tbselenium module. I need to write this list to two output files valid.txt and address.txt, when i run the script i get the result (a list of strings) but nothing is written to the two output files. There is no error raised and the print statements inside the two functions work perfectly. The input is read successfully</p>
  <pre><code>from tbselenium.tbdriver import TorBrowserDriver
  import requests
  import time
  import pandas as pd
  
  def read_input():
      with open('Entries.txt') as fp:
          users = fp.readlines()
      return users
  
  users = read_input()
  result = some_function(users) # This function scrapes the webpage using selenium
  
  def write_output(result):
      with open('valid.txt', 'a+') as fw:
          fw.writelines(result)
          print('Writing to valid.txt', result)
  
  
  def write_addr(result):
      with open('address.txt', 'a+') as fw:
          for x in result:
              fw.write(x.split(':')[5]+'\n')
              print('Writing to address.txt')
  
  write_output(result)
  write_addr(result)
  </code></pre>
  <p>I then tried writing the same output to a csv file.</p>
  <pre><code>df = pd.DataFrame(result)
  print(df)
  df.to_csv('valid.csv', mode='a', header=False)
  </code></pre>
  <p>The dataFrame is created but nothing is written to the csv file. It is not even created if i haven't already created one in my folder.
  If i don't run the scraping function and try to write something to the output files then it works.</p>