Write() implementation