I'm trying to write a script that reads in a bunch of files and printing out lines that meet a certain criteria. The script will first find a line that contains "Robot". Once it find this line, it will check the next line if it contains "Change" if it does print the line. If next line still contain "Change", print line out until next line no longer contains the string "change"

Here's what i have so far:

searchterm = "Robot"

Code:
import fileinput, sys, string
searchterm, sys.argv[1:] = sys.argv[1], sys.argv[2:]

for line in fileinput.input():
   num_matches = string.count(line, searchterm)
   if num_matches:
      #go to next line and check if it has "change"info

       change_matches = string.count(line, "CHANGE")
       while change_matches:
             print line
	#go to next line

             change_matches = string.count(line, "CHANGE")
Can anyone help me out? I'm new to python.