Why not just create a buffer and read/write to that?