Write environment into file