auto replace \t and remove trailing spaces