public static void main(String[] args) {
    
        Scanner words;
        HashSet<String> dict = new HashSet<String>();
        Scanner userFile;
        
        try {
        
            words = new Scanner(new File("words.txt"));
        
            while (words.hasNext()) {
                String word = words.next();
                dict.add(word.toLowerCase());
            }
            
            userFile = new Scanner(getInputFileNameFromUser());
            
            // Skip over any non-letter characters in the file.
            userFile.useDelimiter("[^a-zA-Z]+");
            
            HashSet<String> badWords = new HashSet<String>();
            while (userFile.hasNext()) {
                String userWord = userFile.next();
                userWord = userWord.toLowerCase();
                if (!dict.contains(userWord) && 
                    !badWords.contains(userWord)) {
                    
                    badWords.add(userWord);
                    TreeSet<String> goodWords = new TreeSet<String>();
                    goodWords = corrections(userWord, dict);
                    System.out.print(userWord + ": ");
                    if (goodWords.isEmpty())
                        System.out.println("(no suggestions)");
                    else {
                        int count = 0;
                        for (String goodWord: goodWords) {
                            System.out.print(goodWord);
                            if (count < goodWords.size() - 1)
                                System.out.print(", ");
                            else
                                System.out.print("\n");
                            count++;
                        }
                    }
                    
                }
            
            }
            
        }
        catch (FileNotFoundException e) {
            System.exit(0);
        }
    
    } // end main()