Fixed Segfault in readen function