why do you need to compare count=0 ?
You should drop this condition since the next time the loop comes back the reord has moved to next position. that's why you may be getting a indefinite loop.
Also, i think you should write a Exit statement where your criteria matches in the loop.
Hope this helps.