You can read all the numbers from your file and store them into a hash. Then, you can check if a random number exists in your hash. If you show us the format of your file, we can provide further guidance.
Comment on Re: Check randomly generated numbers have not been used before