You are getting the error because the script never breaks out of the while loop. This is because the comparitor in the while satement "while diff > 0.0001" is dependant on the variable "diff" which is never altered inside of the while loop, so here is what happens...
After the script runs the code that is inside the while loop, it checks the comparitor statement "diff > 0.0001", if it evaluates to true, the while loop executes the code inside of it again and then checks the comparitor again and so on until the comparitor evaluates to false, at which time the script exits the while loop and continues on to the next line. Since "diff" never gets alterd inside the while loop, every time the while loop checks the comparitor, it will decide to continue, hence the infinite recursion error.
In general, you need to be careful when setting up a while loop so that the variable(s) in the comparitor are being changed from within the while loop or that there is some other exiting mechanism inside the while loop or you will get this problem.
It is an easy mistake to make though, I still do it sometimes myself.
Hope that helps =)