Avoid infinite loop when no change to the buffer has occured (fixes #55)