Closed streams in replace