begin implementing the write and read loops