removed trailing spaces in the empty lines in mode function.