title: Reading specific data from a text file
body: <p>I have a .dat file that contains over 40,000 lines containing text and data. I want to extract specific data from this file according to the following:</p>
  
  <p>I need a line counter, obviously, so I know when I reach the end of the file. 
  I want to open the file for reading and another for writing, and read the first line. If the line 2 positions from the first line begins with "Model", I want to print a blank line to the file open for writing and then skip two lines ahead in the file. If the line two positions from the opening line does not start with "Model", then I wish to select the text that is 8 positions from this first line and print that to the file opened for writing. I will then move 11 positions from the first line and so on. </p>
  
  <pre><code>infile = open("ratios.dat","r")
  outfile = open("corr_ratios.txt","w")
  
  for aline in infile:
      items = (aline+2).split()
      if items[0] = "Model"
          outfile.write("\n")
          aline = aline+2
      else    
          items = aline+8
          outfile.write(items)
  </code></pre>