Fixed bug where detection of journal number fails for new/empty data
set.
Removed msg() and bail() functions, and changed approach to make the
existing log() and die() functions behave correctly regardless of
whether $LOGFILE is defined.
If $LOGFILE is defined, log() silently write to the log file, otherwise
writes to the screen (stdout).
If $LOGFILE is defined, die() writes to the log file and sends an
email, otherwise writes to the screen (stdout). If on a tty, error
is duplicated in stderr.