Finished implementing write()