title: Python-Write a statement if there is a certain character in a file
body: <p>I finally was helped and was able to count how many specific characters there are in a file, I am trying top enhance the code by writing/printing a line if there is a specific character in a file here is part of the code that I have that is suppose to do that, no errors given, just doesn't work. Any suggestions on approaching this issue?</p>
  
  <pre><code>atom_count = len(set('OHCN').intersection(chain.from_iterable(f1)))
    s = s.replace('ntyp = 11', 'ntyp = {}'.format(atom_count))
    f = open(filename, 'w')
    f.write(s)
    f.flush()
    f.close()
  
    linenum = f.readLines()
  
    if {} == 'H':
         f.write('Hydrogen') + linenum[22]
    elif {} == 'C':
          f.write('Carbon') + linenum[23]
    elif {} == 'N':
          f.write('Nitrogen') + linenum[24]
    elif {} == 'O':
          f.write('oxygen') + linenum[25]
  </code></pre>