Here’s my version, done when I was first learning AppleScript (as an exercise). I used AppleScript “some item of a list” rather than the random number generator because it was much faster. Padding the numbers was just to align the display. printOut could just as well have been written to a file - here it’s just a dialog:
property nums : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49}
set games to the text returned of (display dialog "How many games? " default answer "5") as number
set printOut to ""
repeat games times
set printOut to printOut & rand() & return & return
end repeat
display dialog printOut
to rand()
set lst to {}
repeat until (count lst) = 6
set randomNumber to some item of nums
if randomNumber is not in lst then set lst's end to pad(randomNumber)
end repeat
--> format (insert 3 spaces between numbers)
set AppleScript's text item delimiters to space & space & space
set lst to UpSort(lst) as text
set AppleScript's text item delimiters to ""
return lst
end rand
to UpSort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (count of my_list) times
set the low_item to ""
repeat with i from 1 to (count of my_list)
if i is not in the index_list then
set this_item to item i of my_list
if the low_item is "" then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list
end UpSort
to pad(num) -- add leading space to single digits
set thisNum to num as text
if length of thisNum = 1 then
set num to space & space & num
end if
return num
end pad