Segfault on file opening fixed