You save the value here (and in many other places), but then (AFAICT) you never use it?  A few lines later you get the value again, erasing the previously saved but never referenced htmlContent.value.