Fixed potential bug re missing braces for while loop.