title: computer keeps crashing with read/writing files
body: <p>I am not sure why my computer keeps crashing when using this program I tried editing it by closing the file each time I run but it still crashes.</p>
  
  <pre><code>f = open("testfile.txt", "r")
  text = f.read()
  text = str(text)
  looper= text.count(",")
  f.close()
  god= open("dog.txt","w+")
  god.write("Passwords")
  god.close()
  block=""
  for count in range(looper):
      first= (text.find(','))
      second= (text.find(':'))
      block = text[first:second]
      text = text[:first] + text[second:]
      god= open("dog.txt","a")
       god.write(block)
       god.close() 
  </code></pre>
  
  <p>I am trying to take items from a text file and format them into a new text file.</p>
  
  <p>EDITED CODE:</p>
  
  <pre><code>    f = open("testfile.txt", "r")
      text = f.read()
      text = str(text)
      looper= text.count(",")
      f.close()
      god= open("dog.txt","w+")
      god.write("Testing")
      god.close()
      for count in range(looper):
          block = ""
          first= (text.find(':'))
          second= (text.find(','))
          block= text[first:second]
          text = text[second:]
          text = text[first:]
          print (block)
          god= open("dog.txt","a")
          god.write(block)
          god.close()
  </code></pre>
  
  <p>In the first section of code I didn't have the string block clearing and I didn't have the string text updating so what would happen is that each time it looped block would duplicate it self</p>
  
  <pre><code>    EX:
      loop1) :helloworld
      loop2) :helloworld:helloworld
      loop3) :helloworld:helloworld:helloworld
  </code></pre>
  
  <p>making those two changes fixed the problem.</p>