title: How to store each line of a text file into a python list excluding comments
body: <p>A professor of mine asked me if I had time/desire this summer to figure out why one of his fortran 90 programs is not working in the uncommented version but is in the commented version. The program is a couple thousand line long so I obviously will not be looking for the bug manually.</p>
  
  <p>My idea is the following since I am not an expert programmer but decided to take this task on as a fun/learning assignment and a favor to the professor was to write a python script to read each line of the text files and store each line into a list excluding the lines that are comments (so start with <code>! COMMENT TEXT</code>) and lines that don't contain any code (just linebreaks)</p>
  
  <p>I copied and pasted the commented and uncommented fortran source code removing any indentation into two text file called respectively <code>c.txt</code> and <code>unc.txt</code>. 
  What I have so far is the following: </p>
  
  <pre><code>listCom = []
  esclam = "!"
  with open("c.txt") as f:
      i=0
  
      for line in f:
          line = line.strip()
          if line == "":
              continue
      if line.find(esclam) == -1:
          listCom.append(line)    
  
  for e in listCom:
      print e 
  </code></pre>
  
  <p>This was to check if each line in the commented version text file was being stored correctly in the list but it is not working correctly. I might be making the problem more difficult than it is. Any suggestions are much appreciated. My plan was to repeat the same process for the uncommented text file and then compare the two lists entry by entry by using a flag variable to tell me at what entry the 2 differ or that they don't differ at all.</p>
  
  <p>An example of the fortran 90 source code for the commented version pasted in the <code>c.txt</code> file is:</p>
  
  <pre><code>! When this subroutine is run at double precision, 
  ! a good number is 7.
  
  
  use constants
  implicit none
  
  complex(kind=double), intent(inout) :: A
  complex(kind=double), intent(in) :: Q
  integer, intent(in):: order,case_type,choice, comp_coeff
  complex(kind=double), dimension(0:MAX_),intent(out) :: D_m
  integer, intent(out):: k_max 
  complex(kind=double),intent(out):: norm
  
  pi=acos(-one)
  
  G_2=cmplx(zero,zero,double)
  G_1=cmplx(zero,zero,double )
  
  !FL=2.0D0**126
  FL=D1mach(2)
  </code></pre>