Ensure file close with finally