def replace_in_file(filename, old_text, new_text):
    """"replace a string in the file with another string"""
    lines = []
    try:
        with open(filename, 'r') as f:
            lines = list(f)
    except IOError:
        print('File %s does not exist.' % filename)
    if lines:
        with open(filename, 'w') as f:
            for line in lines:
                f.write(line.replace(old_text, new_text))
