def writeOutfile(outfile, arr, nams, removed, rmfile=None):
    """
    Writes an alignment stored in a numpy array into a FASTA file.

    Parameters
    ----------
    outfile: str
        Path to FASTA file where the output should be stored
    arr: np.array
        Numpy array containing the cleaned alignment
    nams: list
        List of nams of sequences in the input alignment
    removed: set
        Set of names of sequences which have been removed
    rmfile: str
        Path to file used to log sequences and columns which have been removed

    Returns
    -------
    None

    """
    out = open(outfile, 'w')
    if rmfile is not None:
        rm = open(rmfile, 'a')
        rm.write('Removed sequences:\n')
    else:
        rm = None
    i = 0
    for nam in nams:
        if nam not in removed:
            out.write('>%s\n%s\n' % (nam, ''.join(list(arr[i]))))
            i += 1
        elif rm is not None:
            rm.write('%s\n' % nam)
    out.close()
    if rm is not None:
        rm.close()
