remove duplicated spaces and line ends