<<I am able to display only
One
Three
Five
Seven>>
It is because you are calling the readline method twice in the loop, which will cause the next line to be fetched from file and that line will be skipped eventually. remove line number 17-20 and try again