private static LinkedBuffer newLine(final int indent, final WriteSink sink,
            final WriteSession session, LinkedBuffer lb) throws IOException
    {
        final int totalSize = LINE_BREAK_LEN + indent;
        session.size += totalSize;

        if (lb.offset + totalSize > lb.buffer.length)
        {
            lb = sink.drain(session, lb);
        }

        final byte[] buffer = lb.buffer;
        int offset = lb.offset;

        if (LINE_BREAK_LEN == 2)
            buffer[offset++] = (byte) '\r';

        buffer[offset++] = (byte) '\n';

        for (int i = 0; i < indent; i++)
            buffer[offset++] = (byte) ' ';

        assert offset == lb.offset + totalSize;

        lb.offset = offset;

        return lb;
    }
Before serializing a message/object tied to a schema, this should be called.
protostuff-yaml/src/main/java/io/protostuff/YamlOutput.java