Trying to run/install a list of files in order

I’m pretty new to this whole thing, so I apologize in advance if this is
common knowledge.

I’m trying to get a ruby script to grab a list of files and run them all
one after the other. The initial script will go to a page, download the
list, then use the list to download each one and install it.

The problem is that the list is ever-changing and updating, so I need to
be able to get the script to sort of loop through and, say:

Download $file1
Run $file1
($file1 is complete)
Download $file2
Run $file2
etcetera

I’m stuck in 2 points. First, if the download list is 7 files one day
and 3 files the next, how can I get the script to stop in the right
place? Also, how will it know to only run one at a time and then move
to the next one? How can I get the download script to know when one is
done and it can move on?

Thanks.