Update Main.java

change in the logic of word chain