Implement WriteFile