To do it in one pass you can use this algorithm:
🦛
In reply to Re: File Parsing Question by hippo in thread File Parsing Question by neptuna