in reply to Looping failure

Be sure to use $| = 1 before your prints while debugging. It may in fact be existing the loop without you noticing because of output buffering.