add a function to remove extra spaces in a file