public void flush() {
        System.err.println("Flushing inverted file...");
        for(int entry=0;entry<writeInvFile.length;entry++)
            if(writeInvFile[entry]!=null)
                try{
                    writeInvFile[entry].flush();
                    writeInvFile[entry].close();
                    writeInvFile[entry]=null;
                }catch(Exception e){
                    System.err.println("Cannot flush inverted file.");
                    e.printStackTrace();
                }
        System.err.println("Finished flushing inverted file!");
    }