def print_qm_kind(int_list, element_name, fname, mode='w'):
    """
    Writes the list to the given file, formatted for CP2K to read as qm atom indices.

    @param int_list: The list to write.
    @param element_name: element type to designate
    @param fname: The location of the file to write.
    @param mode: default is to write to a new file. Use option to designate to append to existing file.
    """
    with open(fname, mode) as m_file:
        m_file.write('    &QM_KIND {}\n'.format(element_name))
        m_file.write('        MM_INDEX {}\n'.format(' '.join(map(str,
            int_list))))
        m_file.write('    &END QM_KIND\n')
    if mode == 'w':
        print('Wrote file: {}'.format(fname))
