Fixed error logging, log was directly appended