analyze: Fix `dep` leak and remove `fs.exists` usage

This patch fixes a leaked global variable `dep` and removes the usage
of `fs.exists()`.  `fs.exists` is considered an anti-pattern (see
http://nodejs.org/api/fs.html#fs_fs_exists_path_callback), and can
easily be avoided by checking `err.code`.
Merge pull request #3 from stephenmathieson/fix/leak-remove-exists

analyze: Fix `dep` leak and remove `fs.exists` usage
Handle file output and stdout end cases separately

This avoids errors when the output stream is `process.stdin`.