import wget link_file = open("./dl-links.txt", 'r', encoding='utf-8') link_content = link_file.read().split('\n') link_file.close() for link in link_content: if len(link) > 0: file_name = link.split('/')[-1] try: wget.download(link, out='/download/' + file_name) except Exception as e: print(repr(e) + ': ' + link)