Change popen type to "w" to enable stdout.

- According to popen doc, if "w" is specified, the returned file
descriptor is linked to child's stdin and its stdout is linked to
parent's stdout. It works precisely the opposite way if we use "r".