Portability fixes

Replaces system() calls to touch files with open()