Corrects range where (stop - start)%step != 0

An exact check of iter != end isn't sufficient, because with a range
like range(1, 10, 2), the iterator will jump from 9 to 11, so a more
involved check is necessary.