fixed the append lists function and the write function