Remove trailing spaces, add EOF newlines.