Cleaned up WriteFile