Fix potential data race when there is no incoming data
Keep track of number of input lines processed