public void populateIndex(String index){
		Scanner reader = new Scanner(index);
		String term = "";
		String parent = ""; //Used if there are subterms.
		String subParent = ""; //Used if there are subterms of subterms.
		String ranges = "";
		while(reader.hasNext()){
			String currentTermAndRanges = reader.nextLine();
			//Find the first comma in the line and split off of it.
			int k = 0;
			for(k = 0;k < currentTermAndRanges.length();k++){
				if(currentTermAndRanges.charAt(k) == ','){
					term = currentTermAndRanges.substring(0,k);
					ranges = currentTermAndRanges.substring(k+1);
					break;
				}
			}
			boolean flag = false; //Used to check if the term is already in the index, if so merge with it.
			boolean subTerm = false; //Used to check if the term is a subTerm.
			boolean subSubTerm = false; //Used to check if the term is a subTerm of a subTerm.
			if(term.charAt(0) == '\t'){
				subTerm = true;
				term = term.substring(1);
				if(term.charAt(0) == '\t'){
					subSubTerm = true;
					term = term.substring(1);
				}
			}
			if(!subTerm){
				//check if the index already contains the term.
				int i = 0;
				for(i = 0;i < terms.size();i++){
					if(terms.get(i).getTerm().compareToIgnoreCase(term) == 0){
						flag = true;
						break;
					}
				}
				//The index does not contain the term.
				if(!flag){
					terms.add(new Term(term, ranges));
				}
				else {
					terms.get(i).getRange().parseRanges(ranges);
				}
			}
			else {
				//Find where the parent is in the list.
				int i = 0;
				for(i = 0;i < terms.size();i++){
					if(terms.get(i).getTerm().compareToIgnoreCase(parent) == 0){
						break;
					}
				}
				//The term is a subterm
				if(!subSubTerm){
					//Ensure that the subterm isn't already added, if so append the new ranges.
					if(terms.get(i).hasSubTerms()){
						boolean subTermFound = false;
						int j = 0;
						for(j = 0;j < terms.get(i).getSubTerms().size();j++){
							if(terms.get(i).getSubTerms().get(j).getTerm().compareToIgnoreCase(term) == 0){
								subTermFound = true;
								break;
							}
						}
						//Append on the terms ranges to the current one.
						if(subTermFound){
							terms.get(i).getSubTerms().get(j).getRange().parseRanges(ranges);
						}
						//Assign the current term as a subterm.
						else {
							terms.get(i).assignSubTerm(term, ranges);
						}
					}
					else {
						//Assign the current term as a subterm.
						terms.get(i).assignSubTerm(term, ranges);
					}
				}
				//The term is a subterm of a subterm.
				else {
					//Find where the sub-terms parent is on the list.
					int j = 0;
					for(j = 0;j < terms.get(i).getSubTerms().size();j++){
						if(terms.get(i).getSubTerms().get(j).getTerm().compareToIgnoreCase(subParent) == 0){
							break;
						}
					}
					//Ensure that the subterm of a subterm isn't already added, if so append the new ranges.
					if(terms.get(i).getSubTerms().get(j).hasSubTerms()){
						boolean subTermFound = false;
						int l = 0;
						for(l = 0;l < terms.get(i).getSubTerms().get(j).getSubTerms().size();l++){
							if(terms.get(i).getSubTerms().get(j).getSubTerms().get(l).getTerm().compareToIgnoreCase(term) == 0){
								subTermFound = true;
								break;
							}
						}
						//Append on the terms ranges to the current one.
						if(subTermFound){
							terms.get(i).getSubTerms().get(j).getSubTerms().get(l).getRange().parseRanges(ranges);
						}
						//Assign the current term as a subterm.
						else {
							terms.get(i).getSubTerms().get(j).assignSubTerm(term, ranges);
						}
					}
					else {
						//Assign the current term as a subterm.
						terms.get(i).getSubTerms().get(j).assignSubTerm(term, ranges);
					}
				}
			}
			//Update the parent as the last term entered was not a subterm.
			if(!subTerm){
				parent = term;
			}
			//Update the subParent as the last term entered that was a subterm, but not a subterm of a subterm
			if(subTerm && !subSubTerm){
				subParent = term;
			}
		}
		reader.close();
		Collections.sort(terms);
	}