added option for piping the command output to the file

I added an option to replace the file contents with the stdout of the command. I considered passing either the file name or contents as stdin to the command, but child_process.exec doesn't support setting the stdin.