title: "a" overwrites file instead of appending
body: <p>I have tried every format this could be written in. Whenever Python reaches the line to append to <code>Scores.csv</code>, it overwrites the file instead.</p>
  
  <p>There are no errors, it just won't append. I'm not sure if it's because I'm trying to write to a <code>.csv</code> file instead of <code>.txt</code>, but if it's because of that, there has to be a workaround.</p>
  
  <p>Here is the faulty code:</p>
  
  <pre><code>#OPEN TEMP_SCORES FILE FOR READING
  with open("temp_Scores.csv", "r") as scorefile:
      print("\nDEBUG: temp_Scores.csv is open.")
      reader = csv.DictReader(scorefile)
      for row in reader:
          print("\nDEBUG: Reading temp_Scores.csv..")
          with open("Scores.csv", "w") as scorefile:
              print("\nDEBUG: Scores.csv is open for writing...")
              fieldnames = ["Name", "Class", "Score 1", "Score 2", "Score 3"]
              writer = csv.DictWriter(scorefile, fieldnames=fieldnames)
  
              #This line writes the actual "header" or "titles"
              writer.writeheader()
  
              NameExists = False
              #LOGIC TO DETERMINE WHAT TO WRITE
              #if new user's name is the same as in the file;
              if row["Name"] == UserData["Name"]:
                  NameExists = True
                  print("\nDEBUG: Name was found in temp_Scores.csv. Overwriting line..")
  
                  #if Score 1 doesn't exist;
                  if len(row["Score 1"]) == 0:
                      #makes NEW SCORE 1 the user's score
                      row["Score 1"] = UserData["Score"]
                      #actually write new scores to file
                      writer.writerow({"Name": row["Name"], "Class": UserData["Class"], "Score 1": row["Score 1"], "Score 2": row["Score 2"], "Score 3": row["Score 3"]})
  
                  #if Score 2 doesn't exist;
                  elif len(row["Score 2"]) == 0:
                      #makes NEW SCORE 2 the user's score
                      row["Score 2"] = UserData["Score"]
                      #actually write new scores to file
                      writer.writerow({"Name": row["Name"], "Class": UserData["Class"], "Score 1": row["Score 1"], "Score 2": row["Score 2"], "Score 3": row["Score 3"]})
  
                  #if Score 3 doesn't exist;
                  elif len(row["Score 3"]) == 0:
                      #makes NEW SCORE 3 the user's score
                      row["Score 3"] = UserData["Score"]
                      #actually write new scores to file
                      writer.writerow({"Name": row["Name"], "Class": UserData["Class"], "Score 1": row["Score 1"], "Score 2": row["Score 2"], "Score 3": row["Score 3"]})
  
                  #if all Scores exist already; (update scores)
                  else:
                      #makes NEW SCORE 3 the user's current score
                      newScore3 = UserData["Score"]
                      #makes NEW SCORE 2 the user's OLD SCORE 3
                      newScore2 = row["Score 3"]
                      #makes NEW SCORE 1 the user's OLD SCORE 2
                      newScore1 = row["Score 2"]
                      #gets rid of OLD SCORE 1
  
                      #actually write new scores to file
                      writer.writerow({"Name": row["Name"], "Class": UserData["Class"], "Score 1": newScore1, "Score 2": newScore2, "Score 3": newScore3})
  
                  print("\nDEBUG: Updated new user's line")
  
      #if new user's name DOESN'T exist in the file already;
      if NameExists == False:
          print("\nDEBUG: Name was not found in temp_Score.csv. Appending new line..")
          #saves new user's details into a NEW LINE in the ORIGINAL FILE
          with open("Scores.csv", "a") as scorefile:
              fieldnames = ["Name", "Class", "Score 1", "Score 2", "Score 3"]
              writer = csv.DictWriter(scorefile, fieldnames=fieldnames)
  
              writer.write({"Name": UserData["Name"], "Class": UserData["Class"], "Score 1": UserData["Score"], "Score 2": "", "Score 3": ""})
  
              print("\nDEBUG: Appended new line onto existing file")
  
  #temp_Scores.csv is no longer needed, so we're getting rid of it
  os.remove("temp_Scores.csv")
  print("\nDEBUG: Deleted temp_Scores.csv.")
  </code></pre>
  
  <p>Thanks so much for any help in advance.</p>