title: Need help using Python to parse log file
body: <p>I'm having a problem with a Python script I'm working on that searches a log file for occurances of a text string and if found prints them to another file, I have tried using break but that ends the process and I end up with only one entry in the other file, if I don't use break, it applies the ending statement to all lines not containing the text, basically I want to end up with a logfile with all occurances of the text contained in it, if the text does not occur in any of the lines in the source logfile I want only one line printed to the new logfile saying that nothing was found, this is the code I am trying now - </p>
  
  <pre><code>with open("/var/log/syslog", "r") as vpnfile:
      for line in vpnfile:
          if "failed CHAP" in line:
              print (line,)
          elif "failed CHAP" not in line:    
              continue
          else:
              print ("Nadda")
  </code></pre>