diff --git a/include/seqan3/io/sam_file/output.hpp b/include/seqan3/io/sam_file/output.hpp index c59ab897e0..e6233ceef6 100644 --- a/include/seqan3/io/sam_file/output.hpp +++ b/include/seqan3/io/sam_file/output.hpp @@ -155,7 +155,8 @@ class sam_file_output //!\brief The destructor will write the header if it has not been written before. ~sam_file_output() { - if (header_has_been_written) + // !primary_stream indicates moved-from object + if (header_has_been_written || !primary_stream) return; assert(!format.valueless_by_exception());