diff --git a/src/TNL/Matrices/MatrixReader.h b/src/TNL/Matrices/MatrixReader.h
index 2c3cbb42422507caa6f2435779154320125b6f04..ae0606678f1b9167b10fd4b9e4868847c41c9b99 100644
--- a/src/TNL/Matrices/MatrixReader.h
+++ b/src/TNL/Matrices/MatrixReader.h
@@ -58,7 +58,7 @@ class MatrixReader
                                   IndexType& lineNumber );
    protected:
 
-   static void checkMtxHeader( const String& header,
+   static bool checkMtxHeader( const String& header,
                                bool& symmetric );
 
    static void readMtxHeader( std::istream& file,
diff --git a/src/TNL/Matrices/MatrixReader_impl.h b/src/TNL/Matrices/MatrixReader_impl.h
index 25643d8c701859f970898c2340403c586fcf66bd..476a7327eb4a76a08a66e52624ffca6fc32340d4 100644
--- a/src/TNL/Matrices/MatrixReader_impl.h
+++ b/src/TNL/Matrices/MatrixReader_impl.h
@@ -156,12 +156,12 @@ bool MatrixReader< Matrix >::findLineByElement( std::istream& file,
 }
 
 template< typename Matrix >
-void MatrixReader< Matrix >::checkMtxHeader( const String& header,
+bool MatrixReader< Matrix >::checkMtxHeader( const String& header,
                                                 bool& symmetric )
 {
    std::vector< String > parsedLine = header.split( ' ', String::SplitSkip::SkipEmpty );
    if( (int) parsedLine.size() < 5 || parsedLine[ 0 ] != "%%MatrixMarket" )
-      throw std::runtime_error( "Wrong MTX file header. We expect line like this: %%MatrixMarket matrix coordinate real general" );
+      return false;
    if( parsedLine[ 1 ] != "matrix" )
       throw std::runtime_error( std::string( "Keyword 'matrix' is expected in the header line: " ) + header.getString() );
    if( parsedLine[ 2 ] != "coordinates" &&
@@ -176,6 +176,7 @@ void MatrixReader< Matrix >::checkMtxHeader( const String& header,
       else
          throw std::runtime_error(  std::string( "Only 'general' matrices are supported, not "  ) + parsedLine[ 4 ].getString() );
    }
+   return true;
 }
 
 template< typename Matrix >
@@ -195,7 +196,7 @@ void MatrixReader< Matrix >::readMtxHeader( std::istream& file,
       std::getline( file, line );
       if( ! headerParsed )
       {
-         checkMtxHeader( line, symmetric );
+         headerParsed = checkMtxHeader( line, symmetric );
          if( verbose && symmetric )
            std::cout << "The matrix is SYMMETRIC ... ";
          continue;
@@ -215,6 +216,7 @@ void MatrixReader< Matrix >::readMtxHeader( std::istream& file,
 
       if( rows <= 0 || columns <= 0 )
          throw std::runtime_error( "Row or column index is negative."  );
+      break;
    }
 }