diff --git a/src/classes/PMsr2Data.cpp b/src/classes/PMsr2Data.cpp index a8eeb43f..3b2cc3f8 100644 --- a/src/classes/PMsr2Data.cpp +++ b/src/classes/PMsr2Data.cpp @@ -51,6 +51,13 @@ using namespace boost::algorithm; #include "PMsr2Data.h" +// determine the length of the linebreak string for different systems ('\r' (old) Macintosh, '\n' Unix, "\r\n" DOS) +#if defined(__MSDOS__) || defined(_MSC_VER) +#define INCR 2 +#else +#define INCR 1 +#endif /* __MSDOS__ || _MSC_VER */ + //------------------------------------------------------------- /** *
Write formatted output to column-formatted ASCII output file @@ -1954,9 +1961,10 @@ int PMsr2Data::WriteOutput(const string &outfile, bool db, unsigned int withHead int size(outFile.tellg()); string s; - for (int i(1); i<=size; ++i) { // find the last non-empty line -- this procedure at the moment probably breaks native Windows support + for (int i(INCR); i<=size; i+=INCR) { // find the last non-empty line outFile.seekg(-i, ios::end); getline(outFile, s); + trim(s); // remove whitespace if (s.empty()) { if (i == size) { outFile.seekp(0);