title: How to add strings to a list created by the readlines() function
body: <p>I'm trying to append a string to the list returned by the <code>readlines()</code> function.</p>
  
  <pre><code> number = str(int(input("Number:")))
   input_name = ((input("Lastname:") + (input("Firstname:")))
  
   file = "TXT.txt"
   # Open file with default mode for reading
   f = open(file)
   lines = f.readlines()
   # Loop for each line in the file
   for line in lines:
       # The name is the values indexed from 0 (first character) to -4 (fourth to last character)
      name = line[0:-4]
      # Check if name has been appended before
      if name == input_name:
        # If value of name is input_name, concentrate the number onto the line
        found = True
        print("\nYour name has been found in the file.\n")
        new_line = line[:-1] + "," + number + "\n"
        lines.remove(line)
        lines.append(new_line)
        # Break the loop
        break
     # Otherwise, continue the loop
     else:
         found = False
  f.close()
  
  if found == False:
     with open(file, "a") as f:
       f.write(name + "," + number + "\n")
  </code></pre>
  
  <p>else:
        with open(file, "w") as f:
          for line in lines:
            f.write(line)</p>
  
  <p>When I test it, if the name has already been dumped into the file, it works.
  However when I run the module a second time, the number appended to the list is deleted and is replaced with the new number instead.</p>
  
  <p>E.G.</p>
  
  <p>If I input the name Gerald Tim and the program finds the name in the file, 
  the first time I run it the number will be added to the name, but the second time I run it it deletes the other number replaces it with the new input
  number.</p>
  
  <p>I would like the program not to delete the last number input.</p>