title: Syntax error reading from a text file / Want to assign each line from a text file to a different list
body: <p>I'm trying to make a maths game and I want to implement a high score tracker which saves the high score of the person along with their name in the text file and it does that for every player. If the player plays again then it can recall his high score from the text file. Here is my code so far:</p>
  
  <pre><code>import random
  def game():
      while 1:
          c1 = input("Would you like to play from the beginning?").lower()
          if c1 == "yes":
              lvl1()
          elif c1 == "no":
              print("Your score was:", score)
              main()
              break
          else:
              game()
      quit()
  def lvl1():
      print("LEVEL 1")
      global score
      score = 0
      operators = ("+","-")
      while 1:
          No1 = random.randint(1,10)
          No2 = random.randint(1,10)
          Op = random.choice(operators)
          if Op == "+":
              A1 = No1 + No2
              print("What is", No1, Op, No2,"?")
              answer = float(input("Enter your answer"))
          elif Op == "-":
              A1 = No1 - No2
              print("What is", No1,Op,No2,"?")
              answer = float(input("Enter your answer"))
          if answer == A1:
              print("Correct!")
              score = score + 1
              print(score)
          else:
              print("Incorrect! Try again...")
              game()
          if score == 5:
              break
      print("Congratulations on making it to level 2!")
      lvl2()
  def lvl2():
      print("LEVEL 2")
      global score
      score = 5
      operators = ("+","-","x")
      while 1:
          No1 = random.randint(1,15)
          No2 = random.randint(1,15)
          Op = random.choice(operators)
          if Op == "+":
              A1 = No1 + No2
              print("What is", No1, Op, No2,"?")
              answer = float(input("Enter your answer"))
          elif Op == "-":
              A1 = No1 - No2
              print("What is", No1,Op,No2,"?")
              answer = float(input("Enter your answer"))
          else:
              A1 = No1 * No2
              print("What is", No1,Op,No2,"?")
              answer = float(input("Enter your answer"))
          if answer == A1:
              print("Correct!")
              score = score + 1
              print(score)
          else:
              print("Incorrect! Try again...")
              game()
          if score == 10:
              break
      print("Congratulations on making it to level 3!")
      lvl3()
  def lvl3():
      print("LEVEL 3")
      global score
      score = 10
      operators = ("+","-","x")
      while 1:
          No1 = random.randint(10,50)
          No2 = random.randint(10,50)
          Op = random.choice(operators)
          if Op == "+":
              A1 = No1 + No2
              print("What is", No1, Op, No2,"?")
              answer = float(input("Enter your answer"))
          elif Op == "-":
              A1 = No1 - No2
              print("What is", No1,Op,No2,"?")
              answer = float(input("Enter your answer"))
          else:
              A1 = No1 * No2
              print("What is", No1,Op,No2,"?")
              answer = float(input("Enter your answer"))
          if answer == A1:
              print("Correct!")
              score = score + 1
              print(score)
          else:
              print("Incorrect! Try again...")
              game()
          if score == 15:
              break
      print("Congratulations on making it to level 4!")
      lvl4()
  def lvl4():
      print("LEVEL 4")
      global score
      score = 15
      operators = ("+","-","x")
      while 1:
          No1 = random.randint(10,100)
          No2 = random.randint(10,100)
          Op = random.choice(operators)
          if Op == "+":
              A1 = No1 + No2
              print("What is", No1, Op, No2,"?")
              answer = float(input("Enter your answer"))
          elif Op == "-":
              A1 = No1 - No2
              print("What is", No1,Op,No2,"?")
              answer = float(input("Enter your answer"))
          else:
              A1 = No1 * No2
              print("What is", No1,Op,No2,"?")
              answer = float(input("Enter your answer"))
          if answer == A1:
              print("Correct!")
              score = score + 1
              print(score)
          else:
              print("Incorrect! Try again...")
              game()
          if score == 20:
              break
      print("Congratulations! You have completed the game.")
      main()
  def gethighscore():
      # Default high score
      highscore = 0
  
      # Try to read the high score from a file
      try:
          highscorefile = open("highscore.txt", "r")
          name = str(highscorefile.read())
          highscore = int(highscorefile.read())
          highscorefile.close()
          print("The high score is", highscore)
      except IOError:
          # Error reading file, no high score
          print("There is no high score yet.")
  
  
      return highscore
  
  
  def savehighscore(new_high_score):
      try:
          # Write the file to disk
          highscorefile = open("highscore.txt", "w")
          L = [name, new_high_score]
          highscorefile.write(str(L))
          highscorefile.close()
      except IOError:
          # Hm, can't write it.
          print("Unable to save the high score.")
  
  
  def main():
      # Get the high score
      highscore = gethighscore()
      if score &lt; highscore:
          print("Yea! New high score!")
          savehighscore(score)
      else:
          print("Better luck next time.")
  
  
  print("Welcome to the maths game.")
  name = input("What is your name?")
  print("IT'S TIME!")
  lvl1()
  quit()
  </code></pre>
  
  <p>I am currently getting this error:</p>
  
  <pre><code>Your score was: 2
  Traceback (most recent call last):
    File "D:\A level computer science\Maths game.py", line 182, in &lt;module&gt;
      lvl1()
    File "D:\A level computer science\Maths game.py", line 37, in lvl1
      game()
    File "D:\A level computer science\Maths game.py", line 9, in game
      main()
    File "D:\A level computer science\Maths game.py", line 171, in main
      highscore = gethighscore()
    File "D:\A level computer science\Maths game.py", line 146, in gethighscore
      highscore = int(highscorefile.read())
  ValueError: invalid literal for int() with base 10: ''
  </code></pre>