Fix trailing empty records not being skipped