Fixed critical array length indexing bug.

Also added line counter.