C++程序有关问题,下面的程序是输出wr1.txt文件中的数据,但编译时发现if(f1>>i)这句有有关问题,请教要怎样改?

C++程序问题,下面的程序是输出wr1.txt文件中的数据,但编译时发现if(f1>>i)这句有问题,请问要怎样改???
错误提示:error C2676: binary '>>' : 'class ofstream' does not define this operator or a conversion to a type acceptable to the predefined operator



#include <iostream.h>

#include <stdlib.h>
#include <fstream.h>

void main()
{
ofstream f1("wr1.txt", ios::in|ios::nocreate);
if(!f1)
{
cerr<<"File 'wr1.txt' not found";
exit(1);
}

int i;
while(!f1.eof())
{
if(f1>>i)
cout<<i<<" ";
}
cout<<endl;
f1.close();
}

------解决方案--------------------
ofstream 改成ifstream
------解决方案--------------------
f1<<i
------解决方案--------------------
探讨

ofstream 改成ifstream