iter_lines ported over.
get_pair ported over