Problem solved:

Thanks :) the program is now working ....
and i also gained some experience with the read() method :P i mean seriously i never thought that sometimes the input would depend on the os

(It was an issue of trying to process the newline characters.)