Moved around bash commands so as to not break sftp with echoed data.