title: Python: [WinError 32] issue
body: <p>I'm writing a function to copy each line of a text file into a new one, unless the line is a specially designated one, in which case it will change part of that line and then save the line like normal to the new file.</p>
  
  <p>I'm asking this because I tried using the fixes given in <a href="https://stackoverflow.com/questions/13747577/python-why-am-i-getting-a-winerror-32">this question</a>, but I'm still getting the same error.</p>
  
  <p>To answer potential questions: </p>
  
  <ul>
  <li>I have a file named 'save.txt' that is being renamed to 'oldsave.txt' in order to create a new file named 'save.txt'. </li>
  <li>'rN' is just a integer value generated by another function.</li>
  <li>All the libraries I need have been imported before the function is called</li>
  </ul>
  
  <p>Here's the function:</p>
  
  <pre><code>os.rename(file1,'oldsave.txt') 
  oldSave = open(file1)
  newSave = open('save.txt','a')
  
  count = 1
  for line in oldSave:    
      if count != rN: 
          newSave.write(line)
      else:
          chosen_album = []
          line = line.strip()
          chosen_album.append(line.split('|'))
          chosen_album[4] += 1
          newSave.write(chosen_album)
      count += 1
  oldSave.close()
  newSave.close()
  os.rename('newsave.txt','save.txt')
  os.remove('oldsave.txt')
  </code></pre>
  
  <p>This is the error I get when I run it:</p>
  
  <pre><code>PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'oldsave.txt'
  </code></pre>
  
  <p>As far as I know, the issue lies in the opening/closing/renaming of the files.</p>