add the visting counter and write in file