title: How to fix my leaderboard for my Music Quiz
body: <p>I'm making a Music Quiz for a school project.</p>
  <p>I've made a working game however I cannot get the leaderboard (which should be text and is saved as leaderboard.txt) to show different names as it overwrites the previous name.</p>
  <p>For example, if &quot;Sam&quot; was to get a score of 9 and &quot;Ben&quot; was to get a score of 3, it would show up as &quot;Ben-3-9&quot; which is not what I'm after.</p>
  <p>I am trying to get my leaderboard to work like:</p>
  <pre><code>Sam - 9
  Ben - 3
  ...
  </code></pre>
  <p>My code looks like this right now:</p>
  <pre><code>username = input(&quot;What is your username?&quot;)
  # this will ask for the persons name
  password = str(input(&quot;What is the password?&quot;))
  
  # this will ask for a password which has been set already
  if password == &quot;1234&quot;:
      print(&quot;User Authenticated&quot;)
  
  # if the password is incorrect, tell the user so and exit
  elif password != &quot;1234&quot;:
      print(&quot;Password Denied&quot;)
      exit()
  
  # GAME
  # Creating a score variable
  score=0
  x = 0
  # Reading song names and artist from the file
  read = open(&quot;songnames.txt&quot;, &quot;r&quot;)
  songs = read.readlines()
  songlist = []
  
  # Removing the 'new line' code
  for i in range(len(songs)):
      songlist.append(songs[i].strip('\n'))
  
  while x == 0:
      # Randomly choosing a song and artist from the list
      import random
      choice = random.choice(songlist)
      artist, song = choice.split('-')
  
      # Splitting the song into the first letters of each word
      songs = song.split()
      letters = [word[0] for word in songs]
  
      # Loop for guessing the answer
      for x in range(0, 2):
          print(artist, &quot;&quot;.join(letters))
          guess = str(input(&quot;Guess the song!&quot;))
          if guess == song:
              if x == 0:
                  score = score + 3
                  break
              if x == 1:
                  score = score + 1
                  break
              quit()
  
      # Printing score, Then waiting to start loop again.
      import time
      print(&quot;Your score is&quot;, score)
      print(&quot;Nice Work!&quot;)
      time.sleep(3)
  
  leaderboard = open(&quot;leaderboard.txt&quot;, &quot;r+&quot;)
  leaderboard.write(username + '-' + '{}'.format(score))
  leaderboard.close()
  leaderboard = open(&quot;leaderboard.txt&quot;, &quot;r+&quot;)
  leaderboardlist = leaderboard.readlines()
  print(leaderboardlist)
  leaderboard.close()
  </code></pre>
  <p>PS: this is not 100% my code I am trying to get help from different places as my school has not taught us how to code yet due to the pandemic closing down schools.</p>