fix potential memory leak

use fclose() before return.

Change-Id: I3ed193464cc0dc90e9935ae19162667ad367628b