# "Variable not used"- Problem for open()...do...io function

**URL:** https://discourse.julialang.org/t/variable-not-used-problem-for-open-do-io-function/62563
**Category:** New to Julia
**Created:** [June 8, 2021, 8:06am UTC](https://discourse.julialang.org/t/variable-not-used-problem-for-open-do-io-function/62563 "2021-06-08T08:06:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hardy](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@hardy](https://discourse.julialang.org/u/hardy)
#### Post date: [June 8, 2021, 8:06am UTC](https://discourse.julialang.org/t/variable-not-used-problem-for-open-do-io-function/62563/1 "2021-06-08T08:06:44Z")

</div>

I want to read some variable values from a .tsv file like this:

```julia
# ---------------------------------------------
function readfile(svname)
    algrtm="unknown"
    rbc="unknown"
    
    # read used algorithm and right boundary condition from file
    open(svname) do io # = open...try...finally close
         algrtm = readuntil(io,'-')      
         readline(io) # remove decoration
         rbc = readuntil(io,'-')         
    end
    
    return algrtm, rbc
    end #function
    # ---------------------------------------------
    
    
    svname_nn = "Euler_Neumann2.tsv"     
    algrtm_nn, rbc_nn = readfile(svname_nn)

```

The function works. But I get a problem “Variable has been assigned but not used”. I don’t get this warning for  
algrtm=“unknown”  
rbc=“unknown”  
but for  
algrtm = readuntil(io,‘-’)  
rbc = readuntil(io,‘-’)  
although it’s the same variable, isn’t it?

What is the right way to this?  
I am grateful for any help

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [June 8, 2021, 8:21am UTC](https://discourse.julialang.org/t/variable-not-used-problem-for-open-do-io-function/62563/2 "2021-06-08T08:21:17Z")

</div>

That’s an error with the linter, so don’t worry about it 😉

Ref

> <https://github.com/julia-vscode/StaticLint.jl/issues/291>
>
> \`\`\`
> function readfile(svname)
> algrtm="unknown"
> rbc="unknown"
> 
> o…pen(svname) do io
> algrtm = readuntil(io,'-')
> readline(io)
> rbc = readuntil(io,'-')
> end
> 
> return algrtm, rbc
> end
> \`\`\`
> !\[image\](https://user-images.githubusercontent.com/6735977/121149753-35729d80-c843-11eb-9e10-f8d1afd8fbb7.png)

---

<div class="post-metadata">

### Author: ![hardy](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@hardy](https://discourse.julialang.org/u/hardy)
#### Post date: [June 8, 2021, 10:13am UTC](https://discourse.julialang.org/t/variable-not-used-problem-for-open-do-io-function/62563/3 "2021-06-08T10:13:20Z")

</div>

Thank you for this information
