Optimized import file function to handle storage outside file loop