I got this suggestion from Jeanne A. E. DeVoto ~ jeanne at runrev.com repeat read from stdin until "mystic_mouse" if the result is not empty then add 1 to the_counter -- found it else exit repeat -- encountered end of file, no more occurrences end repeat put the_counter But I was not able to make it actually run. Any suggestions?