<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _add_to_tbz(tfile, filename, data_str):
    '''
    Adds string data to a tarfile
    '''

    # Create a bytesio object for adding to a tarfile
    # https://stackoverflow.com/a/52724508
    encoded_data = data_str.encode('utf-8')
    ti = tarfile.TarInfo(name=filename)
    ti.size = len(encoded_data)
    tfile.addfile(tarinfo=ti, fileobj=io.BytesIO(encoded_data))