Added the writeThenRead method.