fix bug in trim_trailing_newlines and trim_trailing_whitespace