Queue write in Scala