Removing line breaks and spaces from end of files