title: File I/O in Python
body: <p>I'm attempting to read a CSV file and then write the read CSV into another CSV file.</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>import csv 
  with open ("mastertable.csv") as file:
      for row in file:
      print row  
  with open("table.csv", "w") as f:
     f.write(file)
  </code></pre>
  
  <p>I eventually want to read a CSV file write to a new CSV with appended data.</p>
  
  <p>I get this error when I try to run it. </p>
  
  <pre><code>Traceback (most recent call last):
  File "readlines.py", line 8, in &lt;module&gt;
  f.write(file)
  TypeError: expected a character buffer object
  </code></pre>
  
  <p>From what I understood it seems that I have to close the file, but I thought with automatically closed it? </p>
  
  <p>I'm not sure why I can write a string to text but I can't simply write a CSV to another CSV almost like just making a copy by iterating over it.</p>