title: Python continue for loop after exception
body: <p>I'm trying to create a new version of a file that excludes NULL bytes.  I'm using the code below to attempt this however it's still breaking on the NULL byte.  How should I structure the <code>for</code> statement and <code>try-catch</code> block to keep going after the exception?</p>
  
  <pre><code>import csv
  
  input_file = "/data/train.txt"
  outFileName = "/data/train_no_null.txt"
  ############################
  
  i_f = open( input_file, 'r' )
  reader = csv.reader( i_f , delimiter = '|' )
  
  outFile = open(outFileName, 'wb') 
  mywriter = csv.writer(outFile, delimiter = '|')
  
  i_f.seek( 0 )
  i = 1
  
  for line in reader:
      try:
          i += 1
          mywriter.writerow(line)
  
      except csv.Error:
          print('csv choked on line %s' % (i + 1))
          pass
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Here's the error message:</p>
  
  <pre><code>Traceback (most recent call last):
    File "20150310_rewrite_csv_wo_NULL.py", line 26, in &lt;module&gt;
      for line in reader:
  _csv.Error: line contains NULL byte
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>I'm using this code:</p>
  
  <pre><code>i_f = open( input_file, 'r' )
  reader = csv.reader( i_f , delimiter = '|' )
  # reader.next()
  
  outFile = open(outFileName, 'wb') 
  mywriter = csv.writer(outFile, delimiter = '|')
  
  i_f.seek( 0 )
  i = 1
  
  
  for idx, line in enumerate(reader):
      try:
          mywriter.writerow(line)
      except:
          print('csv choked on line %s' % idx)
  </code></pre>
  
  <p>and now get this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "20150310_rewrite_csv_wo_NULL.py", line 26, in &lt;module&gt;
      for idx, line in enumerate(reader):
  _csv.Error: line contains NULL byte
  </code></pre>