update README and reorganize the code
fix a bug that threw an error when piping an output with unicode characters to a file