in reply to Extract the lines

What part are you getting stuck on? Show us some code that shows us what you're doing, and tell us where you're having difficulty. We're not a coding service, after all.

You may want to read Ask questions the smart way, I know what I mean. Why don't you? and How (Not) To Ask A Question.

...roboticus