Have a look at seek to reset the filehandle's position.
In reply to Re: How to read a file twice by linuxer in thread How to read a file twice by Anonymous Monk