modified the read/write to txt with the new format