Hello guys!
I'm having a rather pesky problem working with fstream.
I could write, for example:

fstream file("text.txt");

then file should be open in read/write mode.
But then if I do the following:

file << "Some text";
file >> string_var;

or in the opposite order, it will only perform the first operation. I've even tried with seekp() but it still happens, even if I do:

file << "A word!";
file >> aString;

The only way i've found to fix this is creating two separate fstreams but it seems not right...
Also, if I try to open different files in a loop using only one fstream the same happens.

Is all this supposed to happen? What am i doing wrong?

You can open the stream in both input and output modes -- just use the | or operator fstream file("text.txt", ios::in | ios::out);