Added option to replace current file with output of command. Fixed encoding issue.