Whiledemo errors

Fixed the whiledemo errors, with all this practice on error checking I'm
getting the hang of C++.