The break and continue problem was actually my own mistake. I wrote no_blks = length/4096 + 1, so the loop actually executes twice. Sorry for my idiotic mistake.... But the read() problem still persists..... Thanks..