Improved fix for the newline at the end of crontabs

Fixes issue #15699 and improves PR #15771
Merge pull request #15985 from rallytime/bp-15915

Backport #15915 to 2014.7