writing the count in the files