Something like this should get you going
SQL> declare
2 f utl_file.file_type;
3 l_rows int := 0;
4 l_suffix int := 0;
5 begin
6 for i in ( select * from emp )
7 loop
8 if mod(l_rows,5) = 0 then
9 utl_file.fclose_all;
10 l_suffix := l_suffix + 1;
11 f := utl_file.fopen( 'TEMP', 'file'||l_suffix||'.csv', 'w' );
12 l_rows := 0;
13 end if;
14 l_rows := l_rows + 1;
15 utl_file.put_line(f,i.empno||','||i.ename);
16 end loop;
17 utl_file.fclose_all;
18 end;
19 /
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL> host dir x:\temp\file*.csv
Volume in drive X is SSD
Volume Serial Number is 3E16-F9D0
Directory of x:\temp
26/10/2022 12:11 PM 60 file1.csv
26/10/2022 12:11 PM 60 file2.csv
26/10/2022 12:11 PM 59 file3.csv
3 File(s) 179 bytes
0 Dir(s) 101,855,199,232 bytes free
SQL> host cat x:\temp\file1.csv
7369,SMITH
7499,ALLEN
7521,WARD
7566,JONES
7654,MARTIN