Fixed a bug that caused writing zero records to multiple files