Fix pattern checking for grep and line count in linecounter