But if I uncomment this line, the rpi will not reboot properly using xoff. That's the problem.

The fan script don't work. the fan still running at full speed even if I set the speed to 0.