Use BufEnter event to update syntax
Also fix mistake in the use of len() function.