I says that I have an infinte loop, but when I run the code I get the wanted output