def write_pls_playlist(filename, files):
    """
    Write a PLS playlist named filename containing files.
    """
    out = open(filename, 'w', encoding='utf-8')
    out.write('[playlist]\n')
    count = 0
    for f in files:
        count = count + 1
        out.write('File{0}={1}\n'.format(count, f))
    out.write('NumberOfEntries={0}\n'.format(count))
    out.write('Version=2\n')
    out.close()
