move write to its own file