* avoid using "echo" to write to CLI as php mistakes it for sent headers (see php-src #12303)
* as we are using fwrite now, errors are written to STDERR instead of STDOUT
* fixes an issue where reloading the config would cause "ini_set(): Session ini settings cannot be changed after headers have already been sent" to be spammed