refactored do_extract_chunk
handling blank lines