title: Extract Values between two strings in a text file using python
body: <p>Lets say I have a Text file with the below content</p>
  
  <pre><code>fdsjhgjhg
  fdshkjhk
  Start
  Good Morning
  Hello World
  End
  dashjkhjk
  dsfjkhk
  </code></pre>
  
  <p>Now I need to write a Python code which will read the text file and copy the contents between Start and end to another file.</p>
  
  <p>I wrote the following code.</p>
  
  <pre><code>inFile = open("data.txt")
  outFile = open("result.txt", "w")
  buffer = []
  keepCurrentSet = True
  for line in inFile:
      buffer.append(line)
      if line.startswith("Start"):
          #---- starts a new data set
          if keepCurrentSet:
              outFile.write("".join(buffer))
          #now reset our state
          keepCurrentSet = False
          buffer = []
      elif line.startswith("End"):
          keepCurrentSet = True
  inFile.close()
  outFile.close()
  </code></pre>
  
  <p>I'm not getting the desired output as expected
  I'm just getting Start
  What I want to get is all the lines between Start and End.
  Excluding Start &amp; End.</p>