Accurate sky signal reconstruction for ground-based spectroscopy with kinetic inductance detectors