Only close if Inputstream not null