Jencas is correct. You might want to set a flag to stay in the loop (set to TRUE before entering the loop). Then in the loop set up a nested IF:
IF the coordinates are good
{
IF the location is EMPTY
{
set the flag to FALSE so the loop exits.
}
}