Fixed bug with output redirect