Fix incorrect shell variable name usage

Use $n when referencing variable 'n' in the if condition instead of just 'n' which is incorrect.