title: python Filtering the file contents
body: <p>I am new to python and I am trying to do the following assignment but my output is not the same as the one it is supposed to be. Can any one help me what the problem is here? I appreciate your helps!</p>
  
  <p><strong>Assignment:</strong></p>
  
  <p>In the third program, we take a look into the classification of file contents. In the same directory with the source code is a file "strings.txt", which has random strings in several lines. The lines can be divided into two groups: those which only have letters (a-z, A-Z) and numbers (0-9), and those which also have random special characters (?,&amp;,@, $ ...).</p>
  
  <p>Create a program which reads all of the lines from the file and tests the lines. If the line has only letters and/or numbers, the program prints "[line] was ok.". If the line has special characters, the program should print "[line] was invalid.". When the program works, it prints out something like this:</p>
  
  <pre><code>5345m345ö34l was ok.
  no2no123non4 was ok.
  noq234n5ioqw#% was invalid.
  %#""SGMSGSER was invalid.
  doghdp5234 was ok.
  sg,dermoepm was invalid.
  43453-frgsd was invalid.
  hsth())) was invalid.
  bmepm35wae was ok.
  vmopaem2234+0+ was invalid.
  gsdm12313 was ok.
  bbrbwb55be3"?"#? was invalid.
  "?"#%#"!%#"&amp;"?%%"?#?#"?" was invalid.
  retrte#%#?% was invalid.
  abcdefghijklmnopqrstuvxy was ok.
  </code></pre>
  
  <p>It is advisable to read the lines one at a time, test them with the isalmun() string test and go on from there. Also remember that the strings may also end in a line break (\n), which is allowed, but fails the .isalnum() test if not sliced away.
  Example output</p>
  
  <pre><code>5345m34534l was invalid.
  no2no123non4 was ok.
  noq234n5ioqw#% was invalid.
  %#""SGMSGSER was invalid.
  doghdp5234 was ok.
  sg,dermoepm was invalid.
  43453-frgsd was invalid.
  hsth())) was invalid.
  bmepm35wae was ok.
  vmopaem2234+0+ was invalid.
  gsdm12313 was ok.
  gswrgsrdgrsgsig45 was ok.
  )/(/)(#=%#)%/ was invalid.
  ++-+-+--+--+-+&gt;-&lt;+-&lt;&lt;_&lt;-+&gt;&gt;++ was invalid.
  </code></pre>
  
  <p><strong>my code is</strong></p>
  
  <pre><code>handle = open("strings.txt","r")
  content = handle.read()
  content.isalnum()
  for i in content:
      if content.isalnum()==True:
          print(content,"was ok")
      else:
          print(content,"was invalid")
  
  handle.close()
  </code></pre>
  
  <p><strong>My output is</strong></p>
  
  <pre><code>5345m34534l
  no2no123non4
  noq234n5ioqw#%
  %#""SGMSGSER
  doghdp5234
  sg,dermoepm
  43453-frgsd
  hsth()))
  bmepm35wae
  vmopaem2234+0+
  gsdm12313
  gswrgsrdgrsgsig45
  )/(/)(#=%#)%/
  ++-+-+--+--+-+&gt;-&lt;+-&lt;&lt;_&lt;-+&gt;&gt;++. was invalid
  5345m34534l
  no2no123non4
  noq234n5ioqw#%
  %#""SGMSGSER
  doghdp5234
  sg,dermoepm
  43453-frgsd
  hsth()))
  bmepm35wae
  vmopaem2234+0+
  gsdm12313
  gswrgsrdgrsgsig45
  )/(/)(#=%#)%/
  ++-+-+--+--+-+&gt;-&lt;+-&lt;&lt;_&lt;-+&gt;&gt;++. was invalid
  5345m34534l
  no2no123non4
  noq234n5ioqw#%
  %#""SGMSGSER
  doghdp5234
  sg,dermoepm
  43453-frgsd
  hsth()))
  bmepm35wae
  vmopaem2234+0+
  gsdm12313
  gswrgsrdgrsgsig45
  )/(/)(#=%#)%/
  ++-+-+--+--+-+&gt;-&lt;+-&lt;&lt;_&lt;-+&gt;&gt;++. was invalid
  
  # etc ad nauseum...
  </code></pre>
  
  <p>What am I doing wrong?</p>