Rewrite strategy to correctly write in file