finally found a solution that works!
added slight modifications to the initial script to remove new line characters and concatenate all the lines in each file, because it would give a js error