title: TypeError: argument of type 'file' is not iterable 2.7 python
body: <p>I'm trying to create and write an existing dictionary to a csv file but I keep getting this error which I can't figure out:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/Danny/Desktop/Inventaris.py", line 52, in &lt;module&gt;
      Toevoeging_methode_plus(toevoegproduct, aantaltoevoeging)
    File "/Users/Danny/Desktop/Inventaris.py", line 9, in Toevoeging_methode_plus
      writecolumbs()
    File "/Users/Danny/Desktop/Inventaris.py", line 21, in writecolumbs
      with open("variabelen.csv", "wb") in csvfile:
  TypeError: argument of type 'file' is not iterable
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>And this is the code that gives me the error:</p>
  
  <pre><code>import csv
  import os
  
  def Toevoeging_methode_plus(key_to_find, definition):
      if key_to_find in a:
          current = a[key_to_find]
          newval = int(current) + aantaltoevoeging
          a[key_to_find] = int(current) + aantaltoevoeging
          writecolumbs()
  
  
  def Toevoeging_methode_minus(key_to_find, definition):
      if key_to_find in a:
          current = a[key_to_find]
          newval = int(current) - aantaltoevoeging
          a[key_to_find] = int(current) - aantaltoevoeging
          writecolumbs()
  
  def writecolumbs():
      os.remove("variabelen.csv")
      with open("variabelen.csv", "wb") in csvfile:
          spamwriter = csv.writer(csvfile, delimiter=' ',
                              quotechar='|', quoting=csv.QUOTE_MINIMAL)
          spamwriter.writerow("Product", "Aantal")
          spamwriter.writerows(a)  
  
  
  a = {}
  
  
  with open("variabelen.csv") as csvfile:
      reader = csv.DictReader(csvfile)
      for row in reader:
          a[row['Product']] = row['Aantal']
          print a
  
  print("""
  1. Toevoegen
  2. Aftrek
  3. Check
  """)
  askmenu = int(raw_input("Menu Nummer? "))
  if askmenu is 1:
      toevoegproduct = raw_input("Productnummer &gt; ")
      aantaltoevoeging = int(raw_input("Hoeveel &gt; "))
      Toevoeging_methode_plus(toevoegproduct, aantaltoevoeging)
      print a
  
  elif askmenu is 2:
      toevoegproduct = raw_input("Productnummer &gt; ")
      aantaltoevoeging = int(raw_input("Hoeveel &gt; "))
      Toevoeging_methode_minus(toevoegproduct, aantaltoevoeging)
      writecolumbs(toevoegproduct, newval)
      print a
  
  elif askmenu is 3:
      checknummer = raw_input("Productnummer &gt; ")
      if checknummer in a:
          print a[checknummer]
  
  else:
      print "oops"
  </code></pre>
  
  <p>The csv file contains this information currently:
  Product Aantal
  233     60
  2234    1</p>