title: Replacing a word in a text file with a value using python
body: <p>I have been trying to replace a word in a text file with a value (say 1), but my outfile is blank.I am new to python (its only been a month since I have been learning it).</p>
  
  <p>My file is relatively large, but I just want to replace a word with the value 1 for now.
  Here is a segment of what the file looks like:</p>
  
  <pre><code>NAME SECOND_1
  
  ATOM 1 6 0 0 0 # ORB 1
  
  ATOM 2 2 0 12/24 0 # ORB 2
  
  ATOM 3 2 12/24 0 0 # ORB 2
  
  ATOM 4 2 0 0 4/24 # ORB 3
  
  ATOM 5 2 0 0 20/24 # ORB 3
  
  ATOM 6 2 0 0 8/24 # ORB 3
  
  ATOM 7 2 0 0 16/24 # ORB 3
  
  ATOM 8 6 0 0 12/24 # ORB 1
  
  ATOM 9 2 12/24 0 12/24 # ORB 2
  
  ATOM 10 2 0 12/24 12/24 # ORB 2
  
  #1
  
  #2
  
  #3
  </code></pre>
  
  <p>I want to first replace the word ATOM with the value 1. Next I want to replace #ORB with a space. Here is what I am trying thus far.</p>
  
  <pre><code>input = open('SECOND_orbitsJ22.txt','r')
   output=open('SECOND_orbitsJ22_out.txt','w')
  for line in input:
      word=line.split(',')
      if(word[0]=='ATOM'):
          word[0]='1'
          output.write(','.join(word))
  </code></pre>
  
  <p>Can anyone offer any suggestions or help? Thanks so much.</p>