title: Python - csv file is empty after using csv writer
body: <p>Python newbie here. I was trying to troubleshoot an issue with writing a csv file in a larger program and decided to go back to basics to try to find the problem.</p>
  
  <p>I ran an exact code example from the Python csv reading and writing documention:</p>
  
  <pre><code>import csv     
  spamWriter = csv.writer(open('eggs.csv', 'w'), delimiter=' ', quotechar='|')    
  spamWriter.writerow(['Spam'] * 5 + ['Baked Beans'])
  spamWriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
  </code></pre>
  
  <p>When I go to my working directory and click on "eggs.csv" the file is empty is reported as being "0 kb".  This same thing was happening in my larger program (empty csv files).  Am I missing something completely obvious?</p>
  
  <p>Thank you!</p>
  
  <p><strong>EDIT</strong>:<br>
  I just tried modified the code to:</p>
  
  <pre><code>import csv
  csvOut=open("eggs.csv", "wb")
  spamWriter = csv.writer(csvOut, delimiter=' ', quotechar='|')
  spamWriter.writerow(['Spam'] * 5 + ['Baked Beans'])
  spamWriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
  csvOut.close()
  </code></pre>
  
  <p>And this worked.  I am not sure why the first doesn't work for me.</p>