Well, I'm all for making things simpler, so I've updated it with your suggestion (and keeping all the previous parameters intact). I was a little concerned about testing for eof on every iteration, but it doesn't really make that big of a difference. And I think doing it this way makes it easier to add more options, like setting different 'after' counts for different patterns and such.