title: python search a string in a text file and copy a block
body: <p>I have this text file names.txt</p>
  
  <pre><code>Daniel
  Sam
  Sameer
  Code
  Print
  Alpha
  Bravo
  Charlie
  </code></pre>
  
  <p>and I want to search it for string "Alpha" and copy the line "alpha" and the previous 100 lines then write"append" it to file result.txt</p>
  
  <pre><code> with open(names.txt) as g:
      lines = (g.readlines())
      for line in lines:
          if "{0}".format("Alpha") in line:
            ????????????
  </code></pre>
  
  <p>I writed this code and stopped here , any one could help ?</p>