I needed to save output from SQL query into file. I found this solution:

SQL>SPOOL /tmp/data.dat
SQL>select * from table;
SQL>SPOOL OFF