This does work. The number of output files is always less then 10. I'll have to work on the sort as I get a warning Sorted input from file.txt had unusable data at line 1:
Though it works and I think I'll be able to understand what's going on.
Many thanks,
Gert