added support for input and output redirection