title: Searching between targets in python
body: <p>Sorry to ask a beginner question but I am completely stuck and I very much hope someone can help me.</p>
  
  <p>I have a large document file with sections I want to keep, and bits I would like to be rid of. All the sections I want to keep start "To the Editor: " but they consist of multiple paragraphs (not a consistent number and only the first one starts "To the Editor: ").</p>
  
  <p>The pieces I would like to discard have an initial paragraph with the word "LEAD" and again, they may be several paragraphs long. </p>
  
  <p>I would like a way to use python to move through the document and when it finds an instance of "LEAD", to skip to the next instance of "To the Editor: " but so far I haven't managed anything more than extracting the first bit of text I want.</p>
  
  <p>In case it helps at all, it was with this code (except I indented it properly, honest):</p>
  
  <pre><code>for line in file_to_use:
      if re.search ("LEAD", line):
          break
      else:
          print line
  </code></pre>
  
  <p>But of course that just falls out of the loop when it reaches the first instance of "LEAD". Is there a way to get it to search for the next target ("To the Editor: ") and repeat the process from there?</p>
  
  <p>Thank you very much for any help.</p>
  
  <p>EDIT:</p>
  
  <p>Thank you for editing my original post!</p>
  
  <p>Here's an example of the document:</p>
  
  <p>01.tgz:        <p>To the Editor:  I agree with Mr. Chiswick on the desirability of having an immigration policy that favors applicants for immigration who are most likely to be productive members of American society. However, I think Mr. Chiswick errs when he equates the educational level of the applicant with his probable productivity. I doubt that it can be established that a foreign worker's education level is likely to correlate with his productivity beyond a minimal level.</p>
  01.tgz:        <p>Our experience with Mexican workers in the Mexican in-bond maquiladora manufacturing and assembly industries, for example, is that those workers who have sixth- grade educations are, on the average, from 10 to 25 percent more productive than United States workers (who presumably are better educated) in doing the same tasks. Conversely, university or college education in many foreign countries seems to correlate almost inversely to useful productive skills. ALLEN E. SMITH  Allen E. Smith &amp; Associates  Maquiladora industry consultants  McAllen, Tex., Dec. 29  CORPORATE POWER, CONT.</p>
  01.tgz:        <p>LEAD: A popular Maine district judge is facing his second charge of misconduct in office in two years stemming from his policy of dealing severely with drunken drivers and juvenile offenders.</p>
  01.tgz:        <p>LEAD: A popular Maine district judge is facing his second charge of misconduct in office in two years stemming from his policy of dealing severely with drunken drivers and juvenile offenders.</p> </p>
  
  <p>01.tgz:        <p>Three other Maine judges have been found guilty of misconduct by the State Supreme Court in the last eight years, but Mr. Benoit is the only judge to go before the court twice.</p>
  01.tgz:        <p>''We are outraged at what they are doing to him,'' said Joan Patterson, who, with her husband, operates a veterinary business in Farmington. ''Anybody who tries to do something different, to make something better, gets the flak.'' Ribbons as Show of Support</p>
  01.tgz:        <p>Over the Christmas holidays, Mrs. Patterson handed out 5,200 red ribbons for people to tie on cars to show support for Judge Benoit.</p>
  01.tgz:        <p>''One woman told me Judge Benoit saved her husband's life seven years ago by giving him a harsh sentence,'' Mrs. Patterson said. ''Most people are very supportive of what he's doing.''</p></p>