fix possible file leak