If passed an IO object that responds to #read, #close it after #read