changed write to append