Fix pathological regexp behaviour on large files

Fixes #17.