* @throws IOException
     */
    private void writeTrailer(PTrailer prevTrailer) throws IOException {
        Hashtable<Object,Object> newTrailer = (Hashtable<Object,Object>)
            prevTrailer.getDictionary().clone();
        int oldSize = prevTrailer.getNumberOfObjects();
        int greatestWritten = getGreatestObjectNumberWritten();
        int newSize = Math.max(oldSize, greatestWritten+1);
        newTrailer.put(new Name("Size"), new Integer(newSize));
        long prevTrailerPos = prevTrailer.getPosition();
        newTrailer.put(new Name("Prev"), new Long(prevTrailerPos));
        long xrefPos = xrefPosition;

        // If the previous trailer doesn't know it's position, then we're
        // likely updating a file loaded via linear traversal, which means
        // that we can't chain back to to the previous trailer, and will
        // have to make this new trailer fail input validation, to continue
        // forcing linear traversal. Ideally in such a way that both ICEpdf
        // and Acrobat will support.
        //TODO See if this works with ICEpdf and Acrobat
        if (prevTrailerPos == 0) {
            xrefPos = -1;
        }

        output.write(TRAILER);
        this.writeDictionary(newTrailer);
        output.write(STARTXREF);
        this.writeLong(xrefPos);
        output.write(NEWLINE);
        output.write(COMMENT_EOF);
    }