Fixed bug where passing a negative number (other than EOF) to “isdigit()” gives undefined behavior.
Cleaned up loop.
Compacted the error handling code.