Row count mismatch for input and output file