Do you want to get rid of all of them and just have a single line output?
Then I'd write plain old C code:
main()
{
int c;
while ((c = getchar()) != EOF) {
if (c != '\n' && c != '\r')
putchar(c);
}
}
If on the other hand, you want to just eliminate the newlines at the end of the output of the programs you described above, then just leave off the << endl:
outbatty << str1 << szToken[2] << " " << szToken[3] << " " << szToken[0] << " " << szToken[1] << " " ;
outbatty << szToken[4] << "," << szToken[5] << str2 << szToken[0] << "." << szToken[2] << str3 << szToken[0] << " " ;
outbatty << str4 << szToken[1] << str5 << szToken[2] << str6 << szToken[2] << " " << szToken[3] << " " << szToken[0];
outbatty << " " << szToken[1] << " " << szToken[4] << str7 << szToken[4] << str8 ;
Or are you just trying to get rid of the last newline in the file?
In that case, the usual thing is to rearrange your logic so you output a newline at the start of each line instead of the end of each line. (If you don't want an extra newline at the beginning then add logic to not output a newline the first time.)