Help for level "patrol Buster

I am stuck on the level control buster. (using Lua)

the code i use is:
loop
local enemy = findNearestEnemy()
if enemy then
self:attack(enemy)
End
The problem it keeps telling me is that end is in the wrong place. It says it should be on the very last line, but once I try to put it on the last line, It creates the next line and gives me the same error.

Nevermind I messed around and realized it also wanted me to have an else statement in it.