Update fourth.cpp

Fixed an error in the last while-loop.