File handling fix

See title