def extract_part_trace(reader, writer, range):
    """
    extract range from reader and save to writer
    :param reader:
    :param writer:
    :param range:
    :return:
    """
    assert len(range) == 2, 'range must be in the form of (min, max)'
    maxLine = range[1]
    if maxLine == -1:
        maxLine = len(reader)
    line_count = 0
    for line in reader:
        line_count += 1
        if line_count - 1 < range[0]:
            continue
        if line_count - 1 >= maxLine:
            break
        writer.write(line)
