Fixed linefeed issues in headers

By using trim(), we can make sure there are no unwanted linefeeds in our
headers.