Adding stream.end() to writeLog method