Is this intended to be such a tight spin? The only sleep occurs in the nested if block that always leads to a break; So, if that block is not entered this will loop with no pause.