def write_new_changelog(repo_url, filename, content_lines, dry_run=True):
    heading_and_newline = '# [Changelog](%s/releases)\n' % repo_url

    with io.open(filename, 'r+') as f:
        existing = f.readlines()

    output = existing[2:]
    output.insert(0, '\n')

    for index, line in enumerate(content_lines):
        output.insert(0, content_lines[len(content_lines) - index - 1])

    output.insert(0, heading_and_newline)

    output = ''.join(output)

    if not dry_run:
        with io.open(filename, 'w+') as f:
            f.write(output)
    else:
        log.info('New changelog:\n%s', ''.join(content_lines))
dataset/ETHPy150Open michaeljoseph/changes/changes/changelog.py/write_new_changelog/original