Question about ignoring values

I am doing an assignment and I am reading a list of numbers from an input file which I am supposed to convert to letters.

The first number in the file is the offset increment for example if it is 10 than a=10.

A space is counted if the number is greater than the value for z and a period if the number is less than the value for a. With each space or period the offset is incremented by 1.

We are only supposed to allow one period or space in a row. How do I set it to count the first space or period and then ignore the following ones?