refactor MadLines file encoding setting logic