Write code to print all duplicates in a string array.
Given an array of strings, print each value that appears more than once exactly one time. Preserve the order in which values are first identified as duplicates. Matching is case-sensitive, and repeated occurrences after the first duplicate should not produce additional output.
The function accepts words, a list of strings, and prints each duplicate on its own line. It also returns the printed values as a list for testing.
def print_duplicates(words):