Changed logic, now when there is an error we close the stream