Replaced manual loop with readfile

With some larger files the script timed out during the download. This is an attempt to resolve the problem by using the readfile method.