Fix filetowrite