built random generator body function, along with i/o with files