fix bug exporting file handle instead of contents

- reading handle was also leaked.