<p>Foolewing msessage sent to Conrad:</p>

<p>In Windows, the following program prints "Not good"when the input file is a text file with CR-LF line endings. More comments inline<br>
`int main() {<br>
    std::fstream ifs;<br>
    ifs.open(fname, std::fstream::in);<br>
    if (ifs) {<br>
        std::istream&amp; is = ifs;<br>
        auto loadType = arma::diskio::guess_file_type(is);</p>

<pre><code>    std::cout &lt;&lt; "Load type" &lt;&lt; loadType &lt;&lt; std::endl;
    // output is 0 unknown
    // this is for the same reason the following program prints "Not Good"
   // So I removed the is.good() test in guess_file_type.
  // Now the loadType is 5 (raw_binary) because the last two characters are '\0'.
  // I guess you have to  read character by character until end of file.

    is.clear();        // get length of file:
    is.seekg(0, std::ios::end);
    is.clear();
    auto length= is.tellg();
    is.seekg(0, is.beg);

    // allocate memory:
    char * buffer = new char[length];

    // read data as a block:
    is.read(buffer, length);
    std::cout &lt;&lt; length &lt;&lt; " "&lt;&lt; (is.good()?"Good":"Not Good") &lt;&lt; std::endl;
    ifs.close();

    // print content:
    std::cout.write(buffer, length);

    delete[] buffer;
}

return 0;
</code></pre>

<p>}`</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/mlpack/mlpack/issues/468#issuecomment-154912104">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFOF1b8LWbxsQ7gLywbPYa9I1TtD6ks5pEBFfgaJpZM4Gd7SI.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/issues/468#issuecomment-154912104"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>