Add write() functionality