Use open() / read() / write() instead of fopen() / fread() / fwrite().

This fixes reading from stdin.