title: Java Scanner cannot find word
body: <p>I am sorry if there is something very simple I am missing.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>import java.util.Scanner;
  import java.io.File;
  import java.util.regex.Pattern;
  public class UnJumble
  {
      String[] ws;
      int ind=0;
      public static void main(String args[]) throws Exception
      {
          System.out.println("Enter a jumbled word");
          String w = new Scanner(System.in).next();
  
          UnJumble uj = new UnJumble();
          uj.ws = new String[uj.fact(w.length())];
          uj.makeWords("",w);
  
          int c=1;
          Scanner sc = new Scanner(new File("dict.txt"));
          for(int i=0; i&lt;uj.ws.length; i++)
          {
                Pattern pat = Pattern.compile(uj.ws[i].toUpperCase());
                if(sc.hasNext(pat))
                      System.out.println(c+++" : \'"+uj.ws[i]+"\'");
          }
  
          System.out.println("Search Completed.");
          if(c==1) System.out.println("No word found.");
      }
  
      public void makeWords(String p,String s)
      {
          if(s.length()==0)
                ws[ind++] = p;
          else
                for(int i=0; i&lt;s.length(); i++)
                      makeWords(p+s.charAt(i),s.substring(0,i)+s.substring(i+1));
      }
  
      public int fact(int n)
      {
          if(n==0) return 1;
          else return n*fact(n-1);
      }
  }
  </code></pre>
  
  <p>The <code>dict.txt</code> file is the SOWPODS dictionary, which is the official Scrabble dictionary..</p>
  
  <p>I want to take in a jumbled word, and rearrange it to check if it is present in the dictionary. If it is, then print it out.</p>
  
  <p>When I try <code>tra</code> as input, the output says <code>No word Found.</code>.
  But the output should have the words <code>tar</code>, <code>art</code> and <code>rat</code>.</p>
  
  <p>Please tell me where I am making a mistake. I apologize if I have made a very simple mistake, because this is the first time I am working with <code>Pattern</code>.</p>