def file_to_list(path_to_file, keep_duplicates=True, encoding='utf-8'):
    """Transforms a plain text (txt or csv) file to Python :obj:`list`.

    Args:
        path_to_file (str): A path to plain text file.
        keep_duplicates (bool): If set to False, the output list will not
            contain duplicates. Defaults to True.
        encoding (str): File's encoding. Defaults to "utf-8".

    Returns:
        list: The processed plain text file as a Python :obj:`list`.

    """

    handler = open(path_to_file, "r", encoding=encoding)
    lines = [line.replace("\n", "") for line in handler.readlines()]
    handler.close()

    return lines if keep_duplicates else list(dict.fromkeys(lines))