The code sometimes does not work it exits becuase "y" some times will not be equal to "y1". I dont understand why this is happening.
To verify I just printed out the x, x1, y and y1 before the "exit".
After couple of iterations it exits and it prints as follows.
x=190, y=72, x1=190, y1=72
x=200, y=82, x1=200, y1=81
I observed that Always y1 is less than 1.