public static void main(String[] args) {
        Scanner in = null;         // for input
        PrintStream out = null;    // for output
        BasicMapADT<String, Entry> concord = new BSTBasicMap<String, Entry>();  
                                   // the concordance
        File inFile = null;			//store input file
        File outFile = null;		//store output file

        // Set up where to send input and output

        switch (args.length) {

        case 1:
        	try {
        		inFile = new File(args[0]);     	 
        		in = new Scanner(inFile);
        	} catch (FileNotFoundException ex) {
        		System.out.println("file not found");
        		System.exit(0);
        	}
        	out = System.out;
        	break;

        case 2: 
        	try { 
        		inFile = new File(args[0]);     	 
        		in = new Scanner(inFile); 
        		outFile = new File(args[1]);
        		out = new PrintStream(outFile);
        	} catch (FileNotFoundException ex) {
        		System.out.println("File not found");
        		System.exit(0);
        	}

            break;

        default:
            System.err.println("Invalid command-line arguments");
            System.exit(0);
        }

        // Process the input file line by line
        // Note: the code below just prints out the words contained in each
        // line.  You will need to replace that code with code to generate
        // the concordance.
              
        int lineNum = 1;	 //keeps track of current line number
        while (in.hasNext()) {
            String line = in.nextLine();
            List<String> words = parseLine(line);

            ////////////////////////////////////////
            // replace the code below with your code
            for (String word : words) {
                Entry myEntry = new Entry(word); 
            	try {
            		concord.put(word.toLowerCase(), myEntry);
            		myEntry.getLines().add(lineNum);
            	} catch (DuplicateException ex) {
            		concord.get(word.toLowerCase()).getLines().add(lineNum);
            	}
            }
            lineNum++;
            ////////////////////////////////////////

        } // end while

        // Print out the concordance
        Iterator<Entry> iter = concord.values().iterator();
        while (iter.hasNext())
            out.println(iter.next().toString());

        // Print out the statistics
        int keys = concord.size();
        int pathLength = concord.totalPathLength();
        out.print("# keys: " + keys + "  total path length: " + pathLength);
        double avg = pathLength;
        out.println("  avg path length: " + ((keys  == 0)? 0 :avg/keys));
        
        out.close();
    }