def METHOD_NAME(fname, prefix, license, kept_header = []):
    input = open(fname, 'r')
    ofname = '/tmp/' + fname.split('/')[-1]
    output = open(ofname, 'w')
    for line in kept_header:
        output.write(line + '\n')
    for line in license.split('\n'):
        if len(line)>0:
            output.write(prefix + ' ' + line + '\n')
        else:
            output.write(prefix + '\n')
    for line in input:
        header = len(filter(lambda x: x == line[0:len(x)], kept_header)) != 0
        if (line[0:len(prefix)] != prefix) and (not header):
            output.write(line)
    output.close()
    shutil.move(ofname, fname)