Well, for a start, your code seems to have mismatched curly braces.
You also use the common function name "line" as a variable's name. I'd avoid doing that.
If you are trying to do one loop inside another loop, don't have both of your looping variables named "i".
It's impossible to know how to fix your program/algorithm any more without knowing what the data you're trying to parse looks like.
---
It might help you to work out how you would do it yourself first, before you try writing the code to do it. What are the steps? Which steps do you do over and over again? Can you draw a flowchart that does it?