Fixed finding the array length.

Used the variable tracking the number of elements (and adding one) to
track array length.