check return values of system calls...must check stat correctly