Changed interface to the output->write method to accept an array for more flexibility