Replace the file related calls with UNIX-like system calls

In this commit, I remove all of file related calls such as fopen and
fclose. Use Unix-like system call(e.g. open, close, read)instead of
them.