if Flag = 1 then
nowhere in your code is flag ever set to 1