Tidied up the setup code with regards to checking for command line and $newline.
Don't flush after logging if we're on the command line, it just throws a warning.