default_sysinclude removes whitespace from the end of the lines of the output as well.
Move all initial environment detection to one place