diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 9c8e6f4056..ad68d9d4cd 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -114,6 +114,12 @@ Foam::autoPtr Foam::functionObjects::writeFile::createFile osPtr.reset(new OFstream(outputDir/(fName + ".dat"))); + if (!osPtr->good()) + { + FatalIOErrorInFunction(osPtr()) << "Cannot open file" + << exit(FatalIOError); + } + initStream(osPtr()); }