Better option handling, now also writes to a file