implementing error handling for IO and Scanner Errors