I think when you copy-paste code into the OnlineGDB it gets confused over line end characters.
You should make sure your lines in your file on your computer do not contain \r\n (Windows line endings) but \n only (Linux line endings) before copying the code to OnlineGDB.
If I do this for your code, it runs (but contains further issues).
I'd recommend using Notepad++ and you can click Edit/EOL Conversion/Unix (LF).
Good luck!