Read and write files to txt