Explicitly handle error returned from f.Close()

Thanks @jessta for pointing that out.