title: python When writing to csv file, why does it loop forever with same row?
body: <pre><code>rows = get_rows() #returns a list of rows
  for row in rows:       
    with open('output.csv', 'w') as fp:
      a = csv.writer(fp, delimiter=',')
      try:
        data = compute(row['id']) #does some transforming of data on the row['id'] string data
      except Exception:
        pass
      print data
      a.writerow(data)
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>row1
  row1
  row1
  row1
  </code></pre>
  
  <p>it keeps on going</p>
  
  <p>I expected:</p>
  
  <pre><code>row1
  row2
  row3
  row4
  row5
  so on  
  </code></pre>