import re


def read_and_prep_file(filename):
    """Read contents of a file,remove html tags
    Args: filename(str): a filename with full path to be loaded
    Returns: text(str): a string containing all words
    We read in all lines in a file, join into one long string, remove all html, turn any character that isnt A-Z and ' into a ' ', then remove trailing and leading 's and convert to lower
    """
    with open(filename, 'r') as f:
        clean_text = ''.join(f.readlines())
    clean_text = re.sub('<.*?>', '', clean_text) #remove html lines
    clean_text = re.sub('[^A-Za-z\']', ' ', clean_text) #replace illegal characters with space
    clean_text = re.sub(' \'*',' ', clean_text) #remove leading '
    clean_text = re.sub('\'* ', ' ', clean_text).lower() # remove trailing ' and convert to lower
    return clean_text