Fixed I/O bug