read from one file and write in another