How to write files in Pl/Sql

create or replace directory out_dir as '/tmp/';

declare
f utl_file.file_type;
nomeFile varchar2(50) := 'pippo.txt';
begin
  f := utl_file.FOPEN('OUT_DIR', nomeFile, 'W');
  utl_file.put_line(f, 'pirla');
  if utl_file.is_open(f) then utl_file.fclose(f);
  end if;
end;