import requests


def download_file(url, filename=None):
    """Downloads a file using its URL; does not accept special headers yet.
    """
    if not filename:
        filename = url.split('/')[-1]
    r = requests.get(url, stream=True)
    with open(filename, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024):
            if chunk:  # filter-out keep-alive new chunks
                f.write(chunk)
                f.flush()
    return filename