Modified file handling to improve portability