This is because, in the For loop, you extract the two factors, and what is detected as a factor is n.

This is why, in the Pollard method, one must do the divide GCD check often enough.

You may extent the multiplys at least until B=sqrt(n), but you must check, for numbers like yours every 50's or 100's. If you do not find after the first 100, then continue for another 100.

See Hans Riesel book, prime numbers and computer methods for factorization for more details.