Separate pipe command and printf, and add windows compatibility