get rid of filename with a space at the end