I made this little program that prints out a random line from a file, but whenever I run it (under Windows) the CPU jumps to 100% and it takes up a lot of RAM, and then it ends without outputting anything. Under BSD (FreeBSD, from a shell account) it runs out of memory \very\ quickly. I have yet to try it under Linux but I would expect the same results. I have no idea why it is doing that, and I don't know where else to turn.
The code is attached since posting it messed up the tables because I indent with tabs.