title: Using r+ mode to read and write into the same file
body: <p>I have a script that successfully removes a column from a csv file. Currently it does this by creating a new file. I want it to write to the original file rather than create a new one.
  I’ve tried this by using the r+ mode for open but it’s not working how I want. See notes below. I think r+ mode is the one I need but I’m struggling to find working examples to learn from.</p>
  
  <p>my code:</p>
  
  <pre><code>    import csv
  
      in_file = "Path to Source"
      out_file = "Path to Result"
  
      with open(in_file, 'r', newline='') as inf, \
          open(out_file, 'w', newline='') as outf:
       reader = csv.reader(inf)
       writer = csv.writer(outf)
  
       for r in reader:
           writer.writerow((r[0],r[1],r[2],r[3],r[4],r[5],r[6]))
  </code></pre>
  
  <p>attempt using <code>r+</code> mode:</p>
  
  <pre><code>with open(in_file, 'r+', newline='') as inf:
      reader = csv.reader(inf)
      writer = csv.writer(inf)
  
      for r in reader:
          writer.writerow((r[0],r[1],r[2],r[3],r[4],r[5],r[6]))
  </code></pre>
  
  <p>This fails with the error <code>list index out of range</code></p>