turns out that the problem was that i opened files from DOS/Windows origin which contains the character ^M at the end of the line , the windows version of fread ignores it , but the linux version doesn't leading to this problem