diff --git a/cpp/s2psimh/s2psimh_core.cpp b/cpp/s2psimh/s2psimh_core.cpp index 7f85592d..e0643d8e 100644 --- a/cpp/s2psimh/s2psimh_core.cpp +++ b/cpp/s2psimh/s2psimh_core.cpp @@ -154,7 +154,7 @@ int S2pSimh::Run(span args) return EXIT_SUCCESS; } - simh_file.open(simh_filename, ios::in | ios::out | ios::binary); + simh_file.open(simh_filename, (meta_data.empty() ? ios::in : ios::out) | ios::binary); if (simh_file.fail()) { cerr << "Error: Can't open '" << simh_filename << "':" << strerror(errno) << endl; return EXIT_FAILURE;