remove trailing spaces in document