title: overwrite words in text file with python
body: <p>I created a text file that contains in the first line a counter of created users and the rest of the lines the text contains user name, password..
  for example:</p>
  
  <pre><code>2
  username Name Last_name Password
  username1 Name Last_name1 Password1
  </code></pre>
  
  <p>I'm using the following commands:</p>
  
  <pre><code>def SaveDatA(self):
      #if self.CheckValid() == False:
          #return
      with open("data.txt","a") as f:
          f.write(self.userEntry.get() + " " + self.NameEntry.get() + " " + self.LastEntry.get()+ " " + self.PasswordEntry.get() + "\n")
          self.counter += 1
  </code></pre>
  
  <p>I want to update the counter to the first line</p>