title: Extracting specific sections of text from simple text files
body: <p>I'm very much a newbie when it comes to Python and am struggling with the following task. Hoping someone can help.</p>
  <p>I have a large number of files that share some common characteristics although not all. Within these files are sections of information that I need to extract but ONLY those sections that contain a specific line of text. This is a snippet of the common text in one of the files:</p>
  <p>room 31<br />
  name &quot;Bob&quot;<br />
  no TV outlet 49<br />
  exit<br />
  room 5<br />
  name &quot;Ted&quot;<br />
  service prov 10.1<br />
  outlet 49-50,52<br />
  exit<br />
  room 80<br />
  name &quot;Alice&quot;<br />
  outlet 49-50,52<br />
  dead outlet 1-20<br />
  exit<br />
  room 50<br />
  name &quot;Tim&quot;<br />
  outlet 49<br />
  exit<br />
  room 51<br />
  name &quot;Sue&quot;<br />
  service prov 10.2.0<br />
  outlet 49<br />
  exit</p>
  <p>What I want to output is any section that contains &quot;service prov&quot; (including any additional text on the same line) so using the above as an example, I need the text staring at &quot;room 5&quot; (the number can vary) up to and including &quot;exit&quot;, and the same for &quot;room 51&quot; - like this:</p>
  <p>room 5<br />
  name &quot;Ted&quot;<br />
  service prov 10.1<br />
  outlet 49-50,52<br />
  exit<br />
  room 51<br />
  name &quot;Sue&quot;<br />
  service prov 10.2.0<br />
  outlet 49<br />
  exit</p>
  <p>What is the simplest way to achieve this, bearing in mind the number of lines in the section can vary and appear at any position inside the original text file?</p>
  <p>All suggestions (especially the simple ones) greatly appreciated! Thanks!</p>