Fix two issues with Filesystem::writeUniqueFile

Summary:
  - `fclose()` error code was not checked.
  - Writing 0 bytes would be treated as an error.

Test Plan: Unit test.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, glen

Differential Revision: https://secure.phabricator.com/D7262