I have a service that takes a file and pass it through to the production .While I am passing the file through I get the file stream and set it to a variable within my message and the variable is of type %Ens.StreamContainer. But after all processing and I need to write out my file to a pdf format The file gets written but is a corrupt file since I can not read it I have tried this with asimple pass through everything is fine .But here I do not know what I am doing wrong here is the operation code  set pInput=pRequest.FileStream      ;the variable to hold the status for the method  #dim status as %Status=$$$OK  ;clear the pResponse   kill pResponse      set pResponse=$$$NULLOREF  ;set the file name to the sequence number   set ..Filename=pRequest.NewFileName     ;the filepath set on the settings of this OPERATION    set origDirectory = ..Adapter.FilePath   ;the file directory to drop the file   set ..Adapter.FilePath = ..Adapter.FilePath_"\"_..StubDirectory     ;start writing out file data to the file in filename ;this bit works fine     set:$$$ISOK(status) status= ..Adapter.PutLine(..Filename_"."_..stubExtension,   $CHAR(34)_ pRequest.ClientID_$CHAR(34)_$CHAR(44)_$CHAR(34)_pRequest.UserId_$CHAR(34)_$CHAR(44)_$CHAR(34)_   pRequest.DocumentType _$CHAR(34)_$CHAR(44)_$CHAR(34)_pRequest.Title_$CHAR(34)_$CHAR(44)_$CHAR(34)_pRequest.Description_$CHAR(34)_$CHAR(44)_$CHAR(34)_pRequest.Author _$CHAR(34)_$CHAR(44)_$CHAR(34)_pRequest.DocumentDate_$CHAR(34)_$CHAR(44)_$CHAR(34)_pRequest.FinalRevision_$CHAR(34))    if ($$$ISOK(status))  {   ;set back to the operation settings   set ..Adapter.FilePath = origDirectory     ;set the file name  to write out to   set ..Filename=pRequest.NewFileName_"."_..DocExtension   ;set the filepath on the production settings to this variable   set origDirectory = ..Adapter.FilePath   ;set the new filepath   set ..Adapter.FilePath = ..Adapter.FilePath_"\"_..DocumentDirectory           //here I turn to write out but file is corrupt       Quit:'$IsObject(pInput.Stream) $$$ERROR($$$EnsErrGeneral,"No Stream contained in StreamContainer Request")  Set tFilename=..Adapter.CreateTimestamp(##class(%File).GetFilename(pInput.OriginalFilename),..Filename)  Set status=..Adapter.PutStream(..Filename, pInput.Stream)  Do pInput.%Save() ; re-save in case PutStream() optimization changed the Stream filename            set ..Adapter.FilePath = origDirectory       if ($$$ISOK(status))  {   set pResponse=##class(BSMHFT.DocumentUpload.GenericRESP).%New()   set pResponse.Process="RiOFileOPRN_files Written to their respective directories"   set pResponse.Status=status   set status=pResponse.%Save()  }     }    return status }