Why is the check for `line_index >= 0` needed? It seems quite suspicious. I think you should add more tests with multiple functions in the same file.