Found the issue in order, have not fixed yet

First run through of the for loop happens right after assigning A=B, and
one of the exit conditions was A==B, which will be true both on the
first loop and the proper final loop.