Duplicated code here for settings up the xfer between write and read.  Maybe abstract into another function?