'Iterate through the data and create the needed output.txt file,
appending to file as necessary.'

def create_file(self):

    with open('output.txt', 'w') as output_file:
        for data_element in self.data:
            title = data_element.get('title')
            first_paragraph = data_element.get('first_paragraph')
            abstract = (data_element.get('abstract') or first_paragraph)
            if (abstract is None):
                continue
            anchor = data_element.get('anchor')
            url = data_element.get('url')
            list_of_data = []
            entry = self.get_data('A', title=title, url=url, abstract=abstract, anchor=anchor)
            list_of_data.append(entry)
            replace_dict = {'Coercing': 'Coerce', 'Creating': 'Create', 'Slicing': 'Slice', 'Searching': 'Search', 'Removing': 'Remove', 'Assigning': 'Assign', 'Creating': 'Create', 'Modifying': 'Modify'}
            for (key, value) in replace_dict.items():
                if (key in title):
                    alternate_title = title.replace(key, value)
                    entry = self.get_data('R', alternate_title, redirect_data=title)
                    list_of_data.append(entry)
            entries = []
            for data in list_of_data:
                if (('    A    ' in data[0]) and (data[1] == 'A')):
                    alternate_title = data[0].replace('    A    ', '    ')
                    entry = self.get_data('R', alternate_title, redirect_data=data[0])
                    entries.append(entry)
                elif (('    A    ' in data[2]) and (data[1] == 'R')):
                    alternate_title = data[0].replace('    A    ', '    ')
                    entry = self.get_data('R', alternate_title, redirect_data=data[2])
                    entries.append(entry)
            list_of_data += entries
            for data in list_of_data:
                tsv = '{}\n'.format(' DCTB '.join(data))
                output_file.write(tsv)
