Please note that you included a ">" sign in $imgfile, which is probably nagging you here.