Updated sync script with here document instead of echo