Check if ofstream's file is opened before write to it in Debug class