title: How to delete a line from a text file using the line number in python
body: <p>here is an example text file</p>
  
  <pre><code>the bird flew
  the dog barked
  the cat meowed
  </code></pre>
  
  <p>here is my code to find the line number of the phrase i want to delete</p>
  
  <pre><code>phrase = 'the dog barked'
  
  with open(filename) as myFile:
      for num, line in enumerate(myFile, 1):
          if phrase in line:
              print 'found at line:', num
  </code></pre>
  
  <p>what can i add to this to be able to delete the line number (num)
  i have tried</p>
  
  <pre><code>lines = myFile.readlines()
  del line[num]
  </code></pre>
  
  <p>but this doesnt work how should i approach this?</p>