Convert opens to use unique_fd.

Fixes a potential leak of fds in WriteStringToFile.

Test: I wrote a temporary test that failed the fchmod on host in
Test: WriteStringToFile. I verified this fails with the old code after running
Test: out of fds and passes with the new code.
Change-Id: I168160841e35dd480d59a69bb4aa8176899fbb32
1 file changed