serious optimization

moral of today's commit is:
don't fork grep for each line of a 5000-line file.
this reduces run time (in my case) from 20 minutes to 15 seconds.