title: Multiple python open read and write
body: <p>I have a program that takes in multiple body of texts an gives it a sentiment analysis score. </p>
  
  <p>I have a separate web crawler that crawls per URL and parses the articles body and pass it into a function called <strong>def articleGet(date, body)</strong></p>
  
  <pre><code>f_out = open(OUTPUT_FILE, 'r')
  rowlen = len(f_out.readlines())
  
  print(rowlen)
  
  f_out = open(OUTPUT_FILE, 'a')
  wr = csv.writer(f_out, lineterminator='\n')
  #check if title columns exist
  if(rowlen &lt; 1):
      wr.writerow(OUTPUT_FIELDS)
  
  output_data = get_data(body)
  wr.writerow(output_data)
  </code></pre>
  
  <p>I want to create a csv file with this format</p>
  
  <blockquote>
    <p>date      |      score</p>
    
    <p>11/28/17  |        4</p>
    
    <p>11/20/17  |        5</p>
  </blockquote>
  
  <p>Something like that. So I want to first read the OUTPUT_FILE, whether the title columns (date, score, etc) already exist before appending into the file. I am having trouble with this where this would work only if the .csv file already exist and is empty, but will not create another one if it does not exist</p>