fix bug of adding newline when cwd has multibyte characters