Fix missing while in do-loop