void writeHeader() throws IOException {
        LOGGER.debug("Writing footer - output: {}, writtenHeader: {}, header: \n{}",
                output, writtenHeader, header);
        if (!writtenHeader) {
            if (output != null) {
                // If we are writing to a zip then start a new zip entry before writing the header.
                if (output.isZip()) {
                    output.startZipEntry();
                }

                if (header != null && header.length > 0) {
                    try {
                        // Write the header.
                        output.write(header);
                    } catch (final IOException e) {
                        error(e.getMessage(), e);
                    }
                }

                // Insert a segment marker before we write the next record regardless of whether the header has actually
                // been written. This is because we always make an allowance for the existence of a header in a
                // segmented stream when viewing data.
                insertSegmentMarker();
            }

            writtenHeader = true;
        }
    }
Method to allow subclasses to insert segment markers between records.
stroom-pipeline/src/main/java/stroom/pipeline/writer/AbstractAppender.java