Your loop will only end when all file streams have returned EOF (at the same time). Maybe you meant to use && instead of ||?