I have a lot of questions about your requirements. Can a line have more than one letter? Can the same number appear more than once for the same letter? Can the same letter be repeated anywhere on a line? Or in the file? If the answer to any of these questions is 'yes', what must you do? Is your real data just numbers and letters? If not, how can we tell the difference?