title: object has no attribute 'replace' trying to read a file.txt
body: <p>Before you say it's duplicated... I've read at least 15 other answers and couldn't make it...</p>
  
  <p>I started getting this error while trying to replace an specific line.
  Now it tells me it has no replace attribute... which it had at some point</p>
  
  <p>I just need to add +1 to an specific line everytime a determinated event happens... and tried this.. which probably is a rough solution.</p>
  
  <p>I saw some answers when they create a new file everytime, that wouldn't work since this event is supposed to happen all the time</p>
  
  <p>so what am I asking here is... why the replace function isn't working... and/or  if there is another simpler function for what am I doing.</p>
  
  <p>code:</p>
  
  <pre><code>usercidFile = str(usercid) +".txt"
  
  with open(usercidFile,'r+') as uf:
      lines = uf.readlines()
  
      xName = str(lines[1])
      x = lines[4]    
      xx = lines[2]
      y = int(x)+1
      #it prints all vars until this point
      uf = uf.replace(str(x),str(y))
  </code></pre>
  
  <p>◙◙which wrings the following error:</p>
  
  <pre><code>  File "/home/ubuntu/workspace/bot.py", line 49, in listener
  uf = uf.replace(str(x),str(y))
  AttributeError: '_io.TextIOWrapper' object has no attribute 'replace'
  </code></pre>