Use of Begin IF ,END IF END not working in the sql script

Hi
I have written a script .The script runs properly if i write sql queries .But if i use PLSQL commands of BEGIN if end if , end ,then on running the script the comamds are getting printed on the prompt .

Ex :temp.sql

[define emp_no = &empno 
 
select * from emp where empno = &emp_no;
 
ACCEPT   i_sum    PROMPT 'Do you want the total sal  of all emp? (y;n): ';

 BEGIN
        IF UPPER('&i_sum') = 'Y' THEN
           select sum(sal) from emp ;
         END IF;
   END ;
]

After connecting to the databse at the sql prompt i type @temp.sql .
The fisrt query runs properly .
But the code from BEGIN to END doesnt run it just dispalys on sql prompt .
Please suggest what am i missing .

Try this,
employee.sql

set serveroutput on
set verify off;
define emp_no = &empno; 
select * from emp where empno = &emp_no;
ACCEPT i_sum PROMPT 'Do you want the total sal of all emp? (y;n): ';
declare
v_sal number;
BEGIN
IF (UPPER('&i_sum') = 'Y') THEN
select sum(sal) into v_sal from emp;
dbms_output.put_line('Total_sal ' || to_char(v_sal));
END IF;
END ;
/