@SuppressWarnings("unchecked")
    public T ensureNewline() {
        if (!builderEndsWith(currentState.getBuilder(), getNewline())) {
            write("");
        }
        return (T) this;
    }
Ensures that the last text written to the writer was a newline as defined in
the current state and inserts one if necessary.

@return Returns self.
smithy-utils/src/main/java/software/amazon/smithy/utils/AbstractCodeWriter.java