code: def _replace_lines(fn, startswith, new_line):
    
    new_lines = []
    for line in open(fn):
      if line.startswith(startswith):
        new_lines.append(new_line)
      else:
        new_lines.append(line)
    with open(fn, 'w') as f:
      f.write('\n'.join(new_lines))
docs: Replace lines starting with starts_with in fn with new_line.