Fixed incorrect behavior due to command throwing IOException in all cases
except when stream exists