def buffer_creator(file,divider,start_line, chunk_size): buffer = [] line_number = start_line current_line = 0 divider_count = 0 with open(file,'r',encoding='utf-8') as f: for line in f: current_line += 1 if (current_line <= line_number): continue if (line.strip()== divider): divider_count = divider_count + 1 if divider_count == chunk_size: break continue buffer.append(line.strip()) return current_line,(' ').join(buffer)