title: I/O value error: Operation on closed file
body: <p>I can't see what I'm doing wrong. I'm trying to make the program read an excel file and then create a new file with a similar name and write the excel row to that file.</p>
  
  <p>The error occurs at "for row in excelreader:"</p>
  
  <p>Here's my code:</p>
  
  <pre><code>import os
  import csv
  dirlist=os.listdir("//GOLLUM/tbg2/tbg2/forritGB")
  print dirlist
  for filename in dirlist:
     if ".csv" in filename:
         with open(filename, 'rb') as csvfile:
             excelreader = csv.reader(csvfile)
         file=open("xml_"+dir, 'w+')
         for row in excelreader:
             file.write(row)
     else:
         pass
  </code></pre>