File writing implemented