Change from "FILE *" to "int fd".
Use file descriptors.