Fixed infinite loop on IO operations