Fix a bug waiting to happen in CountByField.

The way this code was written, it would only ever return the
first 99,999 collapsed results. Actually loop over the records
until they're all consumed.