Reading characters until the space key is pressed

Hello,
I want to write a program that receives data from the input and terminates the program as soon as the space key is pressed. I wrote the following program:

function space()
    print("Please write something: ")
    ch = 'a'
    while ch != ' '
        ch = read(stdin, Char)
    end
end

space()

Where is my code wrong?

Thank you.

You need to use the tricks linked in this other thread.

Hi,
Thank you so much.
Isn’t there an easier way? This is easier to do in other programming languages ​​like C++.