need to parse a txt file line by line forward or backward

I need to read a txt file line by line.
On pressing the right arrow buttton it should read the next line.
On pressing the left arrow button it should read the previous line.
The lines are not of fixed length.
platform linux
Please do not double post.
This is a duplicate of http://www.cplusplus.com/forum/beginner/176807/
Topic archived. No new replies allowed.