title: Simple java spell checker / check if the word exists in the dictionary
body: <p>I am coding a simple spell checker. Just to check the spelling of the user text with that of a small dictionary file and compare them.</p>
  <p>The 'dictionary.txt' file contains:</p>
  <pre><code>my
  name
  is
  </code></pre>
  <p>Here is my code to check and compare user text with the dictionary:</p>
  <pre><code>import java.util.Scanner;
  import java.io.File;
  
  public class SpellChecker
  {
      public static void main(String[] args) throws Exception
      {
          Scanner write = new Scanner(System.in);
  
          System.out.println(&quot;Type a sentence and I will check your spelling/correct words :)&quot;);
          String sentence = write.nextLine();
          String[] splitSentence = sentence.split(&quot; &quot;);
  
          for(int i = 0; i &lt; splitSentence.length; i++)
          {
              Scanner read = new Scanner(new File(&quot;dictionary.txt&quot;));
  
              while(read.hasNextLine())
              {
                  String compare = read.nextLine();
  
                  if(compare.equalsIgnoreCase(splitSentence[i]))
                  {
                      System.out.println(splitSentence[i] + &quot; : correct&quot;);
                  }
                  else
                  {
                      System.out.println(splitSentence[i] + &quot; : incorrect&quot;);
                  }
              }
          }
      }
  }
  </code></pre>
  <p>This is the output I am getting.</p>
  <pre><code>Type a sentence and I will check your spelling/correct words :)
  Heyo my name is Ivam
  Heyo : incorrect
  Heyo : incorrect
  Heyo : incorrect
  my : correct
  my : incorrect
  my : incorrect
  name : incorrect
  name : correct
  name : incorrect
  is : incorrect
  is : incorrect
  is : correct
  Ivam : incorrect
  Ivam : incorrect
  Ivam : incorrect
  </code></pre>
  <p>Below is what I expected the output to be:</p>
  <pre><code>Type a sentence and I will check your spelling/correct words :)
  Heyo my name is Ivam
  Heyo : incorrect
  my : correct
  name : correct
  is : correct
  Ivam : incorrect
  </code></pre>