write lines to file helper