You do it by using the facilities the the run-time system offers and putting that code into a library.
For instance, file-handling code depends on how your system deals with files to begin with. On UNIX systems this is done through syscalls with explicitly defined parameters. So what you have to do is write C code that uses the syscalls which do what you want and make that functionality available through extrnally visible C functions. (In the case of UNIX, the OS itself will usually also have been written in C, but that is irrelevant to this question. The method would be the same for a Pascal compiler on a kernel written in C or a C compiler on a Lisp machine.)
This means that you have to repeat the process for every different platform your language implementation should run on. Making the code into a library (in the case of file manipulation, this will probably be the standard library) ensures that the high-level-language programmer doesn't have to learn about the intricacies of file handling on different systems, but need only understand the C files API.