added function to remove trailing whitespace on save