diff --git a/modules/io/src/mol/pdb_writer.cc b/modules/io/src/mol/pdb_writer.cc index 1e4d46e0f18f3118383779303ab9c1780fa9778b..25faae932e3bcb292a26b56ba8628c59a68990b3 100644 --- a/modules/io/src/mol/pdb_writer.cc +++ b/modules/io/src/mol/pdb_writer.cc @@ -397,6 +397,9 @@ PDBWriter::PDBWriter(const String& filename, const IOProfile& profile): multi_model_(false), charmm_style_(profile.dialect=="CHARMM"), is_pqr_(false), profile_(profile), filename_(filename) { + if (!outfile_.is_open()) { + throw IOException("Failed to open: " + filename); + } if (boost::iequals(".pqr", boost::filesystem::extension(filename))) { is_pqr_=true; }