question: private static void appendNewlineIfNecessary ( StringBuffer buf , Writer out ) throws IOException { int len = buf . length ( ) ; if ( ( len != 0 ) && ( buf . charAt ( len - 1 ) != '\n' ) ) { out . write ( '\n' ) ; } }
target:  Appends a newline to the given buffer via the given writer, but only if it isn't empty and doesn't already end with one.