Add an offset to each link for correct node assignment
Bonus: specify an unlimited* number of input files (*if you have enough ram :)