cut trailing spaces on write to file