Measurement of the proton structure function F2 in ep scattering at HERA