try { if ((Object) Integer.parseInt(letter) instanceof Integer){ word=word+" "; output.write(word); break; } }catch(Exception e){}