# Conditional statement stops file writer

**URL:** https://discourse.julialang.org/t/conditional-statement-stops-file-writer/76943
**Category:** New to Julia
**Created:** [February 23, 2022, 12:17am UTC](https://discourse.julialang.org/t/conditional-statement-stops-file-writer/76943 "2022-02-23T00:17:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![spragud2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/spragud2/32/29409_2.png) [@spragud2](https://discourse.julialang.org/u/spragud2)
#### Post date: [February 23, 2022, 12:17am UTC](https://discourse.julialang.org/t/conditional-statement-stops-file-writer/76943/1 "2022-02-23T00:17:26Z")

</div>

Hi, I’m writing code that depends on the FASTX and BioSequences packages.

My hope is that this issue is independent of the packages I am using.

What I am trying to do is very simple… I have a set of fasta entries (A file with a header followed by a sequence, header, sequence, etc…) that I what to extract by a unique ID, which are contained in a set.

When I include this if statement to check for set membership, nothing is written to the file. When I remove the if statement, all the entries are properly written to the file. The remaining code is properly executed in both cases.

My hope is that this issue is independent of the packages I am using. Any ideas?

```julia
function getrecords(in::IO,out::IO,s::Set)
    reader,writer = FASTQ.Reader(in),FASTA.Writer(out)
    for record ∈ reader
        id = identifier(record)
        if id ∉ s
            continue
        end 
        seq = sequence(LongRNA{2},record)
        seq = convert(LongDNA{2},seq)
        write(writer,FASTA.Record(id,description(record),seq)) # must specify this for nanopore! 

    end 
    return 
end 

```

---

<div class="post-metadata">

### Author: ![frtps](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@frtps](https://discourse.julialang.org/u/frtps)
#### Post date: [February 23, 2022, 1:41am UTC](https://discourse.julialang.org/t/conditional-statement-stops-file-writer/76943/2 "2022-02-23T01:41:06Z")

</div>

Could it be that the output has not been flushed to file? So if you explicitly call `close(out)` or `flush(out)` before returning from the function does that fix it?

---

<div class="post-metadata">

### Author: ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)
#### Post date: [February 23, 2022, 9:09am UTC](https://discourse.julialang.org/t/conditional-statement-stops-file-writer/76943/3 "2022-02-23T09:09:25Z")

</div>

My first instinct is that `id ∉ s` is always true

a debugging method could be

```julia
if ! (id ∉ s)
   error("ok, some id are in s, this was a bad idea")         
end 

```
