Your settings are fine. The last step is to split the spool and select statements into another script, as follows:
SET head OFF;
SET feed OFF;
SET trimspool ON;
SET linesize 32767;
SET pagesize 32767;
SET echo OFF;
SET termout OFF;
SET verify OFF;
SET NEWPAGE NONE;
@test.sql
The file "test.sql" will contain the following lines:
SPOOL filename.csv;
SELECT * from table;
SPOOL OFF;
HTH,
Martin