Fixing open file bug