continuation-passing style I/O