Remove trailing spaces and empty lines at the end of files