title: Program that adds unique words from text file to an ArrayList
body: <p>I am writing a program that reads a text file with multiple lines of text and adds unique words to an ArrayList. Then, I need to sort this ArrayList and print it.
  My input is: </p>
  
  <blockquote>
    <p>Hello my<br>
    my name is<br>
    Java.</p>
  </blockquote>
  
  <p>I originally thought my problem was that once the Scanner hit a word that is already in the ArrayList, it stopped. But, after changing my input, I have no idea what my problem is anymore.
  My output is now:</p>
  
  <blockquote>
    <p>There are 2 unique word(s)<br>
    These words are:<br>
    is<br>
    my</p>
  </blockquote>
  
  <p>I need my output to be:</p>
  
  <blockquote>
    <p>There are 5 unique word(s)<br>
    These words are:<br>
    Hello<br>
    Java<br>
    is<br>
    my<br>
    name<br></p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>import java.util.*;
  import java.io.*;
  public class Indexer
  {
     public static void main(String[] args) throws FileNotFoundException
     {
        Scanner fileScanner = new Scanner(new File("File.txt"));
        fileScanner.useDelimiter("[^A-Za-z0-9]");
        ArrayList&lt;String&gt; words = new ArrayList&lt;String&gt;();
        while (fileScanner.hasNext())
        { 
           if (!words.contains(fileScanner.next()) &amp;&amp; (fileScanner.hasNext()))
           {
             words.add(fileScanner.next());
           }
        }
        Collections.sort(words);
        System.out.println("There are " +  words.size() + " unique word(s)");
        System.out.println("These words are:");
        for (Iterator&lt;String&gt; it = words.iterator(); it.hasNext();) 
        {
            String f = it.next();
            System.out.println(f);
        }
        fileScanner.close();
     }
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>