private boolean builderEndsWith(StringBuilder builder, String check) {
        return builder.length() > check.length()
                && builder.substring(builder.length() - check.length(), builder.length()).equals(check);
    }
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