Spectral behavior of a terahertz quantum-cascade laser