Improved fix for the newline at the end of crontabs

Fixes issue #15699 and improves PR #15771 

To be merged into develop and 2014.7