added file close for destination files

It's a quick fix which closes the file after writing into it.
More code refactor needs to be done which will be taken up next.
Merge pull request #11 from ritesh-pandey/feature/close-file-descriptor

Added file close for destination files in `lib.js`.