Added pipe redirection

This is a fix for issue #298. Simple pipe redirection was not working; this makes it instead keep track of the stream past redirects.