Remove trailing spaces, add missing endlines.