Fixed I/O error by resetting stdin/stdout at end of command