Fixed null data count check

Without this patch only the last output is counted.