private long getDocCount(File file) {
        System.out.println("Counting documents in file ...");
        long startTime = System.currentTimeMillis();
                
        FileInputStream localFis = null;
        GZIPInputStream localGis = null;
        InputStreamReader localReader = null;
        BufferedReader localBuffer = null;
        long total = 0;
        try {
            localFis = new FileInputStream(file);
            if (file.getName().endsWith(".gz") || file.getName().endsWith("gzip")) {
                localGis = new GZIPInputStream(localFis);
                localReader = new InputStreamReader(localGis);
            } else {
                localReader = new InputStreamReader(localFis);
            }

            localBuffer = new BufferedReader(localReader);
            
            String s;
            while ((s = localBuffer.readLine()) != null) {
                total ++;
            }
        } catch (IOException ie) {
            ie.printStackTrace();
        } finally {
            try {
                if (localBuffer != null) {
                    localBuffer.close();
                }
                if (localReader != null) {
                    localReader.close();
                }
                if (localGis != null) {
                    localGis.close();
                }
                if (localFis != null) {
                    localFis.close();
                }
            } catch (IOException ie) {
                ie.printStackTrace();
            }
        }

        System.out.println("Counted " + total + " docs in " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds");

        return total;
    }