Phil,
Here is the code. It still does it with any file starting with
anything!
Thanks!
Mary
@@@@@@@@@@@@@@@@@@@@@@@
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string line;
int main()
{
ifstream in("INPUT.txt",ios::in);
if (!in) {
cout << "Cannot Open the INPUT file.\n";
return 1;
}
ofstream out("OUTPUT.txt",ios:

ut);
if (!out) {
cout << "Cannot Open the OUTPUT file.\n";
in.close();
return 1;
}
while (getline(in,line)) {
if( ! line.empty() ) {
out.write(line.c_str(),line.size());
out.put('\n');
}
}
in.close();
out.close();
return 0;
}
@@@@@@@@@@@@@@@@@@@@@@@@
On Sun, 13 Mar 2005 21:26:05 -0700, Phil Staite <>
wrote:
>Seems odd. Maybe, just maybe there is an empty or blank line at the
>beginning of your source file? In that case during the first iteration
>of the while loop line would be empty. Now, it *should* be ok to call
>write with a char count of 0 and have it do nothing... But maybe there
>is a problem with your stream code? Try adding a simple test:
>
>while (getline(in,line)) {
> if( ! line.empty() )
> {
> out.write(line.c_str(),line.size());
> out.put('\n');
> }
>}