Synthesis of sulfur-containing heterocycles using thionyl chloride or sulfur chlorides