Reimplemented buffered reading and writing with new io module