fixed undefined variable reference

$filename is undefined at this place