title: How to extract lines numbers that match a regular expression in a text file
body: <p>I'm doing a project on statistical machine translation in which I need to extract line numbers from a POS-tagged text file that match a regular expression (any non-separated phrasal verb with the particle 'out'), and write the line numbers to a file (in python).</p>
  
  <p>I have this regular expression: '\w*_VB.?\sout_RP' and my POS-tagged text file: 'Corpus.txt'.
  I would like to get an output file with the line numbers that match the above-mentioned regular expression, and the output file should just have one line number per line (no empty lines), e.g.:</p>
  
  <p>2</p>
  
  <p>5</p>
  
  <p>44</p>
  
  <p>So far all I have in my script is the following:</p>
  
  <pre><code>OutputLineNumbers = open('OutputLineNumbers', 'w')
  with open('Corpus.txt', 'r') as textfile:
      phrase='\w*_VB.?\sout_RP'
      for phrase in textfile: 
  
  OutputLineNumbers.close()
  </code></pre>
  
  <p>Any idea how to solve this problem?</p>
  
  <p>In advance, thanks for your help!</p>