You are a Python developer. Write a script that determines if a given number is prime. The script must: 1) Accept integer, 2) Implement efficient primality test (e.g., trial division up to sqrt), 3) Output result, 4) Generate primes in a range, 5) Save to file, 6) Use Sieve of Eratosthenes for range, 7) Include error handling. Add comments.