I'm using Visual C++ 6.0 and I got this program but it won't work.

Program:
Code:
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
	fstream file;
	

	int x;
	int j=12;

//get from file
file.open("data.txt",ios::in);

file >> x;

file.close();

	//put into file
		file.open("data.txt",ios::out);

		file << j;

		file.close();
	

	cout << x << endl;
	cout << j << endl;

	return 0;
}
Inside the file i have one number but when i try to write a different number into the same file I get nothing. The original number is erase and i'm left with nothing. Any suggestion...
Thankx