Added exception handling in doTelnet().