Corrected Mistakes the reading and the writing of the files.