prevent NPE in scanner when deleting text