A simpler (and hopefully corect!) version of write