title: opening csv with r+ and it is writing to the end of the file
body: <p>I am trying to get the data from a .csv file, separate it into a list of tuples, do stuff with this, then save the changes back to the csv file. My issue is that instead of replacing the data I have it is adding the changes as new lines at the bottom of my file. I am trying to avoid reopening the file and using the csv module. The code below is me opening it, saving it as my list of tuples, and trying to save this back to the file, however it is instead appending the file.</p>
  
  <pre><code>items_data = open("test.csv", "r+")
  my_list = items_data.read().strip().split('\n')
  for line in range(len(my_list)):
      my_list[line] = tuple(my_list[line].split(","))
  for i in range(len(my_list)):
      for a in range(0,4):
          if a==3:
              items_data.write(my_list[i][a] + "\n")
          else:
              items_data.write(my_list[i][a] + ",")
  items_data.close()
  </code></pre>