Use a separate pipe for termination as suggested by Gabriel Gonzalez