Integer Factorization loop problem

Hello, people!
So i wrote a little program that should decompose numbers into smaller divisors (integer factorization), but when i was running it for the first time, i encountered a problem: the program was getting stuck after outputting first divisor. Here's the code btw: