anchor.diff:        if (allocated(dYdz)) deallocate(dYdz)
         if (allocated(dZdz)) deallocate(dZdz)
         if (allocated(dZdu)) deallocate(dZdu)
  -      if (allocated(ipiv)) deallocate(ipiv)     
  +      if (allocated(ipiv)) deallocate(ipiv)
         
         if (allocated(dUdu)) deallocate(dUdu)
         if (allocated(dUdy)) deallocate(dUdy)
  +      
  +      if (Un > 0) close(Un)
  +
      end subroutine cleanup
   END SUBROUTINE FAST_Linearize_OP   
   !----------------------------------------------------------------------------------------------------------------------------------
  
positive.code: !> Routine that writes the A,B,C,D matrices from linearization to a text file. 
  SUBROUTINE WrLinFile_txt_End(Un, p_FAST, LinData)
  
     INTEGER(IntKi),           INTENT(IN   ) :: Un                  !< unit number
     TYPE(FAST_ParameterType), INTENT(IN   ) :: p_FAST              !< parameters
     TYPE(FAST_LinType),       INTENT(IN   ) :: LinData             !< Linearization data for individual module or glue (coupled system)
     
  
negative.code:    
     ErrStat = ErrID_None
     ErrMsg = ""
     Un = -1
  
     
     LinRootName = TRIM(p_FAST%OutFileRoot)//'.'//trim(num2lstr(m_FAST%NextLinTimeIndx))
  