add semicolons and remove trailing whitespace