Allow redirect stdout

Bug: Does not close the file descriptor when finished.