diff --git a/GaudiCommonSvc/src/PersistencySvc/OutputStream.cpp b/GaudiCommonSvc/src/PersistencySvc/OutputStream.cpp
index f6f3b3aa7cb35128b5699906e8413802aea5a5d5..f194b0a6044cedf2ac9d17b5d259c986c98b4571 100644
--- a/GaudiCommonSvc/src/PersistencySvc/OutputStream.cpp
+++ b/GaudiCommonSvc/src/PersistencySvc/OutputStream.cpp
@@ -54,6 +54,11 @@ StatusCode OutputStream::initialize() {
   auto status = Algorithm::initialize();
   if ( status.isFailure() ) return status;
 
+  if ( m_output.empty() ) {
+    fatal() << "property Output not set. OutputStream instances require an output" << endmsg;
+    return StatusCode::FAILURE;
+  }
+
   // Reset the number of events written
   m_events = 0;
   // Get access to the DataManagerSvc
diff --git a/GaudiExamples/tests/pytest/test_outputfile_not_defined.py b/GaudiExamples/tests/pytest/test_outputfile_not_defined.py
new file mode 100644
index 0000000000000000000000000000000000000000..615ee7522e874a078820e91b5b954c5b59d33b09
--- /dev/null
+++ b/GaudiExamples/tests/pytest/test_outputfile_not_defined.py
@@ -0,0 +1,47 @@
+#####################################################################################
+# (c) Copyright 2023 CERN for the benefit of the LHCb and ATLAS collaborations      #
+#                                                                                   #
+# This software is distributed under the terms of the Apache version 2 licence,     #
+# copied verbatim in the file "LICENSE".                                            #
+#                                                                                   #
+# In applying this licence, CERN does not waive the privileges and immunities       #
+# granted to it by virtue of its status as an Intergovernmental Organization        #
+# or submit itself to any jurisdiction.                                             #
+#####################################################################################
+import os
+import sys
+
+from GaudiTests import run_gaudi
+
+
+def config():
+    """
+    Configure a job writing to an empty file.
+    """
+    from Configurables import GaudiPersistency
+    from GaudiConfig2 import Configurables as C
+
+    GaudiPersistency()
+
+    out = C.OutputStream(
+        ItemList=["/Event#999"],
+    )
+    app = C.ApplicationMgr(EvtMax=1, OutStream=[out.__opt_value__()])
+
+    return [app, out]
+
+
+def test(tmp_path):
+    """
+    Check that an output file is created even if no event is written to it.
+    """
+    os.chdir(tmp_path)
+
+    result = run_gaudi(
+        f"{__file__}:config", capture_output=True, errors="surrogateescape"
+    )
+    print(result.stdout, end="")
+    print(result.stderr, end="", file=sys.stderr)
+
+    assert result.returncode == 1
+    assert "OutputStream instances require an output" in result.stdout