Answer

 

This is both the number of moles of carbon in CO2 and therefore the number of moles of carbon in the hydrocarbon.

 

Again, this is both the number of moles of hydrogen in the water and in the hydrocarbon.
For the empirical formula, take the element that has the least number of moles. In this example, it is carbon. Now we will find the smallest mole ratio.

 

This is already the smallest integer ratio (we can say that for hydrogen, it is 2). So the empirical formula is CH2