moved \n\r replacement code to prevent wasting application time
added autonewline code