Implementation of reverse string.