Open file streams with correct input/output mode