Finished implementation of write method. Needs testing.