fixed temp file remove before closing header