title: Deleting and inserting a score into a text file form python
body: <p>I have created a text based game in python 3.3 were users pick a class for their character. I want the game to store three scores so an average can be taken. My problem is that i am unsure how to get the program to search for a name in the file and delete there oldest score, This is what the file where the scores are saved looks like:</p>
  
  <pre><code>Bennie
  33
  62
  94
  Josh
  82
  55
  31
  Jackie
  10
  4
  3
  </code></pre>
  
  <p>My current code that sees if they have done the game before and if not writes there score to the file if they have i have got the code to split the lines and read them. It needs to delete the score closet to their name and insert and new score just before the next name but i am unsure how to do this. This is my current code</p>
  
  <pre><code>    class_choice = input('Enter Class one, Class two or Class three.')
      if class_choice == "One":
          text_file = 'class1.txt'
      elif class_choice == "Two":
          text_file = 'class2.txt'
      elif class_choice == "Three":
          text_file = 'class3.txt'
      else:
          False
      first_time = input('Is this the first you have completed this game: Yes or No?')
      if first_time == 'Yes':
          with open(text_file, "a") as file:
              file.write("{}\n".format(name))
              file.write("0\n")               
              file.write("0\n")   
              file.write("{}\n".format(score))                
              sys.exit()
      else:
          file = open(text_file, 'r')
          lines = file.read().splitlines()    
  </code></pre>