Added append flag to write functions