title: Fortran. Keep reading first word of the document until it matches the input.
body: <p>Good evening!
  I am trying to read a text document in Fortran 95 and do some calculations with the values in it. The document has numerous gas names and certain values of 'A' assigned to them. So essentially it look something like this:</p>
  
  <pre><code>Document 1: gas values.
  GAS     A1  A2
  steam    1  2
  air      3  4
  </code></pre>
  
  <p>I want then the user to input a gas name (variable <strong>gasNameIn</strong>) and implement while loop to keep searching for the gas until it matches the input. So eg. user inputs '<strong>air</strong>' and the program starts reading first words until air comes up. It then read values of <strong>A1</strong> and <strong>A2</strong> and uses them for calculation. What I did for it is that I opened the file as <strong>unit 25</strong> and tried the following loop:</p>
  
  <pre><code>do while(gasName .NE. gasNameIn)
    read(25, *) gasName
    if (gasName .EQ. gasNameIn)
      read(25,*) A1, A2
    endif
  enddo
  </code></pre>
  
  <p>but I get an error "<em>End of file on unit 25</em>".
  Any ideas on how my while loop is wrong? Thank you!</p>