a function used to count the number of duplicated items in a file