Ensure file handles are closed using with statement