Use proper stdin options in child_process.spawn() instead of passing a file child.stdin.end()

Passing a file child.stdin.end() wasn't working in my case, so I decided to rewrite this code in a recommended way.