Sequential to csv

Hello, im a cobol beginner
here is my code to delete space from a sequential file ,but if try to replace with a coma it replaces all the spaces , is there a way to only replace the first space and delete the others ?
IDENTIFICATION DIVISION.
PROGRAM-ID. CPYFILES.
AUTHOR. M.

   ENVIRONMENT DIVISION.
   INPUT-OUTPUT SECTION.
   FILE-CONTROL.
   SELECT MY-INPUT-FILE ASSIGN TO
   "C:\Users\Hp\Documents\my_input.txt"
           ORGANIZATION IS LINE SEQUENTIAL.
   SELECT MY-OUTPUT-FILE ASSIGN TO
   "C:\Users\Hp\Documents\my_output.txt"
           ORGANIZATION IS LINE SEQUENTIAL.
   DATA DIVISION.
    FILE SECTION.
   FD MY-INPUT-FILE.
   01 MY-INPUT-LINE    PIC X(380).
   FD MY-OUTPUT-FILE.
   01 MY-OUTPUT-LINE   PIC X(381).
   WORKING-STORAGE SECTION.
   01 END-OF-FILE PIC X VALUE SPACE.
      88 END-OF-INPUT-FILE VALUE 'T'.
      88 NOT-END-OF-INPUT-FILE VALUE 'F'.
   
   01 i  pic 9(3) value zero .
   01 j pic 9(3) value 1 .
   PROCEDURE DIVISION.
  
     OPEN INPUT MY-INPUT-FILE
     OPEN EXTEND MY-OUTPUT-FILE

     SET NOT-END-OF-INPUT-FILE TO TRUE

     PERFORM UNTIL END-OF-INPUT-FILE
       READ MY-INPUT-FILE
         NOT AT END
         
           PERFORM VARYING i from 1 by 1 until i>80
           If MY-INPUT-LINE(i:1)= SPACE
             continue
            ELSE
                MOVE MY-INPUT-LINE(i:1) to MY-OUTPUT-LINE (j:1)
            
           
           END-IF
           END-PERFORM
           WRITE MY-OUTPUT-LINE
         AT END
            SET END-OF-INPUT-FILE TO TRUE
       END-READ
     END-PERFORM
     CLOSE MY-INPUT-FILE
     CLOSE MY-OUTPUT-FILE
     STOP RUN.

sample input : 000000002300 Wilsonten Wileyie 23232MainVStreet,e#
000000002400 Xrayonten Xaviere 2424224THVStreet,e#
000000002500 Youngnten Yannire 25252YongeSStreete#
000000002600 Zenithten Zebulon 2626226THeStreette#
000000123456 Doeithten Johnlon 1236MainHStreettte#
000000999999 Smithhten Johnlon 12399aEnStreetttte#
sample outputs :
000000000100AndersonAdrian1113PeachtreePlaz
000000000100AndersonAdrian1113PeachtreePlaz

try this:

PERFORM UNTIL END-OF-INPUT-FILE
       READ MY-INPUT-FILE
         NOT AT END
         
	     J = 1
	     space-found = 0

           PERFORM VARYING i from 1 by 1 until i>80
           
           If MY-INPUT-LINE(i:1) not = SPACE
                MOVE MY-INPUT-LINE(i:1) to MY-OUTPUT-LINE (j:1)
			j = j + 1
            ELSE
			if space-found = 0
			   space-found = 1
			else
			   MOVE MY-INPUT-LINE(i:1) to MY-OUTPUT-LINE (j:1)
			   j = j + 1
                  end-if     
           END-IF

           END-PERFORM
           WRITE MY-OUTPUT-LINE
         AT END
            SET END-OF-INPUT-FILE TO TRUE
       END-READ
     END-PERFORM

Thank you ,
is there a way to replace the first space with a coma and delete the others.

PERFORM UNTIL END-OF-INPUT-FILE
       READ MY-INPUT-FILE
         NOT AT END
         
	     J = 1
	     space-found = 0

           PERFORM VARYING i from 1 by 1 until i>80
           
           If MY-INPUT-LINE(i:1) not = SPACE
                MOVE MY-INPUT-LINE(i:1) to MY-OUTPUT-LINE (j:1)
			j = j + 1
            ELSE
			if space-found = 0
			   space-found = 1
MOVE MY-INPUT-LINE(i:1) to MY-OUTPUT-LINE (j:1)
			   j = j + 1       
			else
			   MOVE MY-INPUT-LINE(i:1) to MY-OUTPUT-LINE (j:1)
			   j = j + 1
                  end-if     
           END-IF

           END-PERFORM
           WRITE MY-OUTPUT-LINE
         AT END
            SET END-OF-INPUT-FILE TO TRUE
       END-READ
     END-PERFORM
1 Like
PERFORM UNTIL END-OF-INPUT-FILE
       READ MY-INPUT-FILE
         NOT AT END
         
             J = 1
             space-found = 0

           PERFORM VARYING i from 1 by 1 until i>80
           
             If MY-INPUT-LINE(i:1) not = SPACE
                MOVE MY-INPUT-LINE(i:1) to MY-OUTPUT-LINE (j:1)
                        j = j + 1
             ELSE
                if space-found = 0
                   space-found = 1
                   MOVE ‘,’           to MY-OUTPUT-LINE (j:1)
                   j = j + 1
                end-if     
             END-IF

           END-PERFORM
           WRITE MY-OUTPUT-LINE
         AT END
            SET END-OF-INPUT-FILE TO TRUE
       END-READ
     END-PERFORM