Check the conditions before entering a loop