Bug 1021142 - 'fclose()' at 2 places to avoid leaks on failure. r=bbondy