looping problem

 scan = 0;

Is that in the correct place?