use file pointers for random