Yes, that's right.
Online GDB runs on a server, and your program can only access resources available on the server.
Adding your input file to your project is your best solution.
If, for some reason, the .dat extension confuses the compiler, call it a .txt file instead; that should work and be ignored by the compiler.