Added 'write' function.