I'd like to see the reader and writer sections of this method extracted into separate methods (and/or possibly a common method). There's a little bit of duplication between the two. Perhaps you could get rid of the duplication when extracting?