Fix file handling

See title