add close method to iostream