get the first line of each group