Probably because you're referring to a local file on your machine, but OnlineGDB is running on a Linux server. It has no access to your local files.
You can add any file to your project (left of the RUN button) and you can provide a relative path to that file. See the "Random.txt" in this example added to the project.
If this does not help, please, share your code.