Fixed open file descriptors

Fixed issue #12. All temp files file descriptors were
never being closed, leading to too many open files.