You need to seed the pseudo-random number generator with something other than... nine.
Typically, we seed the generator with variables that are affected by time to get seemingly random numbers.
You can do this by writing:
srand((time_t)time(0));
instead of
srand(9);
You'll have to #include <ctime> though.
The reason you only write one number to your file is because... you're only writing one number to your file.
In your for() loop, you assign a random value to random_integer one-hundred times, and you print the value each time.
Then the loop ends, you create an output file stream object, and you write random_integer to it, which still holds the last random number you generated.
To answer your first question, random_integer is just one integer whose value gets updated in your for loop. Hence it just outputs the last random number generated to the file.
To solve this problem, bring the file output statement within the for loop like cout.
For your second question, you are providing the same seed to the random generator everytime it is run (9). Hence, same set of random numbers shall be generated.
To solve it use srand( time(NULL) ) after including <ctime> header.