import requests


def download_file(url: str, prefix=""):
    """Download file by streaming and writing to file.

    Args:
        url: download url.
        prefix: prefix for output file.
    """
    local_filename = url.split("/")[-1]
    with requests.get(url, stream=True) as r:
        r.raise_for_status()
        with open(prefix + local_filename, "wb") as f:
            for chunk in r.iter_content(chunk_size=8192):
                if chunk:
                    f.write(chunk)
    return local_filename