use printf inplace of echo - echo fails somehow to escape \n and \r chars