code: function(str, pattern)
  	{
  		// LATER: Check is this can be done with a regular expression
  		var postfix = '';
  		
  		while (str.length > 0 && str.charAt(str.length - 1) == '\n')
  		{
  			str = str.substring(0, str.length - 1);
  			postfix += pattern;
  		}
  		
  		return str + postfix;
  	}
docs: Function: replaceTrailingNewlines
  
  Replaces each trailing newline with the given pattern.