remove trailing spaces and log