Added write metod and solved compilation errors