Another option would be to test only the eof condition in the do while portion and then use an exit do when icount reaches 5