Fix fold_file_loop

The fold_file_loop function had a bug (a misoptimization, really) that
caused it to fail to fold over files that were exact multiples of the
chunk size the outside fold was using to iterate with.  In addition to
the misoptimization, this also goes against POSIX semantics by
treating short reads as an exceptional case, rather than something
that can happen at any read.

The fix makes each of the inner fold functions check all matches for
potential end of input.  The outer fold never tries to guess, but
reads until the inner fold says it is done, or eof is reached. I was
worried that this would cause a performance problem, but the perf
testing scripts show no or negligible impact.

cc @bsparrow435 @engelsanchez 

fixes #171