public int tokenCount() {
    	int count = 0;
    	
    	try {
            input = new Scanner(this.file);
        } catch (FileNotFoundException fileNotFoundException) {
            System.err.println("Error opening file.");
        }
    	
    	try{ 
    	   while(input.hasNext()){
    		   input.next();
    		   count++;
    	   }
    	} catch (NoSuchElementException elementException) {
            System.err.println("File improperly formed.");
            input.close();
        } catch (IllegalStateException stateException) {
            System.err.println("Error reading from file.");
        } finally {
            if (input != null)
                input.close(); // close the Scanner and the file
        } // end try-catchfinally
    	return count;
    }