def update_section(lines, new_lines, old_section_start=None,
                   old_section_end=None):
    """
    lines: list of strings; text of .inp file read into list of strings
    new_lines: list of strings; list of strings for replacing old section
    old_section_start: int; position of line where replacing should start
                       (will append to end of file if 'None' and section end
                       is 'None' passed as argument)
    old_section_end: int; position of line where replacing should end

    """
    if old_section_start and old_section_end:
        del lines[old_section_start: old_section_end]
    else:
        old_section_start = len(lines)

    lines[old_section_start: old_section_start] = new_lines
    return lines