* @return The length of the current sub-section
     * @throws IOException
     */
    private int writeXrefSubSection(int beginIndex) throws IOException {
        int beginObjNum = entries.get(beginIndex).getReference().getObjectNumber();

        // Determine how many entries in this sub-section
        int nextContiguous = beginObjNum + 1;
        for(int i = beginIndex+1; i < entries.size(); i++) {
            if (entries.get(i).getReference().getObjectNumber() == nextContiguous)
                nextContiguous++;
            else
                break;
        }
        int subSectionLength = nextContiguous - beginObjNum;

        // Output sub-section header
        writeInteger(beginObjNum);
        output.write(SPACE);
        writeInteger(subSectionLength);
        output.write(NEWLINE);

        for(int i = beginIndex; i < (beginIndex+subSectionLength); i++) {
            Entry entry = entries.get(i);
            if (entry.isDeleted()) {
                // 10-digit-integer:nextFreeObjectNumber SPACE 5-digit-integer:generationNumber SPACE 'f' CRLF
                writeZeroPaddedLong(entry.getNextDeletedObjectNumber(), 10);
                output.write(' ');
                writeZeroPaddedLong(entry.getReference().getGenerationNumber()+1, 5);
                output.write(' ');
                output.write('f');
                output.write('\r');
                output.write('\n');
            }
            else {
                // 10-digit-integer:byteOffset SPACE 5-digit-integer:generationNumber SPACE 'n' CRLF
                writeZeroPaddedLong(entry.getPosition(), 10);
                output.write(' ');
                writeZeroPaddedLong(entry.getReference().getGenerationNumber(), 5);
                output.write(' ');
                output.write('n');
                output.write('\r');
                output.write('\n');
            }
        }

        return subSectionLength;
    }