in reply to Error using grep

You chop the keyword, but you do not chop the lines. chomp might be better for both.