public Index indexDocumentBlob(File blobFile, int numberOfDocuments) throws IOException, FileNotFoundException{
        Trie<IDocument> indexImplementation = new Trie<IDocument>(suggestionCacheSize, hasSortedIndex);
        HashSet<String> indexTermSet = new HashSet<String>();

        try {
            Scanner scanner = new Scanner(blobFile);
            scanner.useDelimiter("#NEW RECORD\n");
            int counter = 0;
            while (scanner.hasNext()){

                String document = scanner.next();

                if(!document.equals("\n")){
                    StringTokenizer st = new StringTokenizer(document, "\n");
                    assert st.countTokens() == 5;

                    String pmid = st.nextToken();
                    String pubdate = st.nextToken();
                    String title = st.nextToken().substring(8);
                    String text = st.nextToken().substring(11);
                    counter++;
                    MedlineDocument medlineDocument = new MedlineDocument(title, title);

                    StringTokenizer documentTokens = new StringTokenizer(text, " ");
                    indexTokens(indexImplementation, documentTokens, medlineDocument, indexTermSet);
                    StringTokenizer titleTokens = new StringTokenizer(title, " ");
                    indexTokens(indexImplementation, titleTokens, medlineDocument, indexTermSet);
                    if(counter % 10000 == 0){
                        System.out.println("Indexed " + counter);
                    }
                }

                if(counter >= numberOfDocuments){
                    break;
                }
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
            System.out.println("File not found.");
            System.exit(1);
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("Error in document processing.");
            System.exit(1);
        }

        System.out.println("Sorting data.");
        indexImplementation.sortData();
        System.out.println(
                "Successfully indexed " + indexImplementation.getNumberOfEntries() + " different index terms.");

        return new Index(indexImplementation, indexTermSet);
    }