A - write function

added the write function