Fixes.

Fixed the WriteEnv usage and updated to allow for sudo if necessary.