Trying to convert a string to an integer adds an extra 0 on x86_64 assembly

I created this function for converting a string taken from standard input to an integer:

str2int:
    mov rax, 0

    L2:
        cmp byte [input + r10], 0
        je done2

        add al, [input + r10]
        sub rax, '0'
        imul rax, 10

        inc r10
        jmp L2

    done2:
    ret

but when i use it, it adds an extra 0 at the end of the number (example: a 1 gets turned into a 10, a 30 into a 300 and so), what is the problem with it?