Updated temp file logic