optimized next_line function in treeBuilder module