remove trailing whitespace and semicolons