Fixing bug in writeHead