Prevent NullPointerException and illegal characters when asking for input