Are you sure fid is valid after fopen? I would enable debugging with debug_in_error (1) then run your script. The interpreter will stop in line 6 and you can inspect fid, i and so on. If you don't solve this yourself please upload your data file and provide a link so someone can test. -- Andy