use env vars for configuration
don't re-use a file-handle because if the file gets deleted then writes will fail silently