I don't know what's wrong with this code. I want to count from a blast report, how many hits correspond to a specific species (the keyword). So my idea is to loop through each line and when the keyword is found, add 1 to count and go to the next line, this because sometimes the name of the species is present more than once in the subject name.
#!/usr/bin/python
import sys
      ##usage: python filterbyword.py file keyword
file = open(sys.argv[1],'r')
keyword = sys.argv[2]
count = 0
for line in file:
    while True:
        if keyword not in line:
            continue
        else:
            break
    count = count + 1
print count
                    
                
                
what's wrong with `grep` ?
I was gonna ask that (along with why not awk for more advanced grepping), but maybe OP wishes to add this functionality as a module to existing code?
OMG you are right! How didn't I think about grep. Shame on me!!