getFile function

auxiliary function to download files in a protected fashion, i.e. against errors in the downloading procedure