Yeah, while() loops must be used very carefully. They're really only useful when you absolutely know that your while will terminate soon after the call.
It's better to use a for() loop. Here's an example of a for() loop used in place of a while() loop:
%client.hasThisProperty = 1;
while(%client.hasThisProperty)
{
//do stuff here
}
%client.hasThisProperty = 1;
for(%i = %client.hasThisProperty;%i >= 1;%i = %client.hasThisProperty)
{
//do stuff here
}