I am trying to get a program that will allow a user to input a filename, then the program will search through the file for < and > and change them to &lt; and &gt;
then this will then output a newfile with the changes
I have tried but whenever I run it asks for the file name which I input a file, then asks for the name I should give the output which I do. Then it closes. It does create a new file but the new file has nothing inside of it.
I was wondering what is wrong with my code since it seems as the program never opens the input file.

#include <string>
#include <iostream>
#include <fstream>

using namespace std;

int main()
{

ofstream outStream;
string fileoutput_name;
string filename;

cout << "Name your file ";
cin >> filename;
getchar ();

fstream file( filename.c_str() );




string searchString("<");
string searchString2 (">");
string replaceString( "&lt;");
string replaceString2("&gt;");



string::size_type i = 0;

while ( (i = filename.find(searchString, i)) != string::npos ) {
filename.replace( i, searchString.size(), replaceString );
i++;
}

while ( (i = filename.find(searchString2, i)) !=string::npos ) {
filename.replace( i, searchString2.size(), replaceString2 );
i++;
}
cout << " What would you like to name the file to where these\n"
<< " random numbers will be stored?\n";
cin >> fileoutput_name;

outStream.open(fileoutput_name.c_str());

getchar ();
return 0;
}