Need help removing carriage return from a text file using a batch script



Text file contains data in the vertical form




Need batch script to convert to following


@echo off
    setlocal enableextensions disabledelayedexpansion

    set "first=1"
    <nul (
      for /f "usebackq delims=" %%a in ("input.txt") do (
        if defined first (set /p ".=%%a" & set "first=") else (set /p ".=,%%a")
    ) >"output.txt"

For each input line, if it is the first, output the line without a line feed, else output a command and the line, also without a line feed.

To supress a line feed, set /p ".=textToOutput" is used, but as we are redirecting the input stream to read from nul, it will not pause for input but echo the prompt without a line feed and continue.

All the output from the for loop is sent to the target file