Made the while loop prettier.

I felt like it.
Also, just for the record, stringstreams are too high leveled. You can write a decent character to integer function easily. No need to transform it to a stringstream and then back to an integer. 
Or if you're feeling really lazy, there's a host of standard c++ atoi functions. Either way, stringstream is extraneous.