Only trim whitespace between non-whitespace and newline (Issue #158)

This prevents trimming lines that only have whitespace.