Never use sintax like this, or it provide many bugs:
1) whay should we read and write file in memory, throw all the filtres, we can coll CopyFile() or MoveFile(), it optimized by the OS.
2) aspecialy for 'fstreams' they are incorrectly working with '\n', '\r' symbols, so in case of this syntax you will get new file with doubbled '\n' ...

ifstream inputFile("c:\\temp.txt",ios::binary);

ofstream outputFile("c:\\temp2.txt",ios::binary);

outputFile << inputFile.rdbuf();


for detailed usage, you can go to MSDN library