added a function to trim whitespace on save